使用path命令,再加mark配合,例子里得到一组蓝色交点,一组绿色交点,我的问题是:在这个path命令(环境)之外,如何引用每个交点,或得到每个交点坐标?
\documentclass[tikz]{standalone}
\usetikzlibrary{decorations.markings}
\usetikzlibrary{intersections,through,calc}
\begin{document}
\begin{tikzpicture}
\draw[->] (0,0) -- (8,0)node[right]{$X$};
\draw[->] (0,0) -- (0,3) node[right]{$Y$};
\draw [line width=1pt,name path=l] plot [domain=-0.16:3.6, samples=20] ({2*\x-0.2*(sin(atan(cos(\x r))))},{sin(\x r)+0.2*(cos(atan(cos(\x r))))});
\path [decorate, decoration={markings,
mark=between positions 0 and 1 step 1/5 with{
\draw[name path=v] (0,-5pt)--(0,26pt);
\draw [name intersections={of=v and l, by={a}}][very thick,blue,fill=black] (a) circle(2pt);
\draw [shift={(0,0)},teal!30,line width=0.5pt,name path=c](0,0)circle(0.6);
\draw [name intersections={of=v and c, by={a}}][very thick,green,fill=black] (a) circle(2pt);
}
}] {plot [domain=0:3.14, samples=10] ({2*\x-0.2*(sin(atan(cos(\x r))))},{sin(\x r)+0.2*(cos(atan(cos(\x r))))})};
\end{tikzpicture}
\end{document}
用一个计数器,每执行一次 mark,就增加 1,坐标点随之改变。
\documentclass[tikz]{standalone}
\usetikzlibrary{decorations.markings}
\usetikzlibrary{intersections,through,calc}
\newcounter{intercnt}
\begin{document}
\begin{tikzpicture}
\draw[->] (0,0) -- (8,0)node[right]{$X$};
\draw[->] (0,0) -- (0,3) node[right]{$Y$};
\draw [line width=1pt,name path=l] plot [domain=-0.16:3.6, samples=20] ({2*\x-0.2*(sin(atan(cos(\x r))))},{sin(\x r)+0.2*(cos(atan(cos(\x r))))});
\setcounter{intercnt}{0} % 初始化
\path [decorate, decoration={markings,
mark=between positions 0 and 1 step 1/5 with{
\stepcounter{intercnt} % 加 1
\edef\pointA{A-\arabic{intercnt}}
\edef\pointB{B-\arabic{intercnt}}
\draw[name path=v] (0,-5pt)--(0,26pt);
\draw [name intersections={of=v and l, by={\pointA}}][very thick,blue,fill=black] (\pointA) circle(2pt);
\draw [shift={(0,0)},teal!30,line width=0.5pt,name path=c](0,0)circle(0.6);
\draw [name intersections={of=v and c, by={\pointB}}][very thick,green,fill=black] (\pointB) circle(2pt);
}
}] {plot [domain=0:3.14, samples=10] ({2*\x-0.2*(sin(atan(cos(\x r))))},{sin(\x r)+0.2*(cos(atan(cos(\x r))))})};
\foreach \i in {1,...,\arabic{intercnt}}
{\node at (A-\i) {$A_\i$}; \node at (B-\i) {$B_\i$};};
\end{tikzpicture}
\end{document}