![画线到正确的圆圈](https://linux22.com/image/323908/%E7%94%BB%E7%BA%BF%E5%88%B0%E6%AD%A3%E7%A1%AE%E7%9A%84%E5%9C%86%E5%9C%88.png)
我有以下代码
\def\aes{in*0.75}%%
\begin{tikzpicture}[scale=0.34mm]
\coordinate (A) at (0,0);
\coordinate (B) at ($(A)+(30:4\aes)$);
\coordinate (C) at ($(B)+(-90:2.5\aes)$);
\draw[line width=2pt,gray!60,postaction={draw,black,dashed,line width=1.4pt}] (A) circle (\aeRadiusA);
\draw[red] (B) circle (\aeRadiusB);
\draw[blue] (C) circle (\aeRadiusC);
\coordinate (A1a) at ($(A)+(-20:\aeRadiusA*0.75)$);
\coordinate (C1a) at ($(C)+(90+20:\aeRadiusC*0.75)$);
\coordinate (A1b) at ($(A1a)+(3pt,2pt)$);
\coordinate (C1b) at ($(C1a)+(0pt,-2pt)$);
\coordinate (A2a) at ($(A)+(30:\aeRadiusA*0.65)$);
\coordinate (B2a) at ($(B)+(140:\aeRadiusB*0.65)$);
\coordinate (A2b) at ($(A2a)+(15pt,4pt)$);
\coordinate (B2b) at ($(B2a)+(-4pt,3pt)$);
\begin{scope}[rotate=280]
\fill[red!20] (B2a) circle (4pt);
\foreach \x in {-3,...,5}{
\draw[blue,shorten >= rand*15] (B2a) -- (rand*\x:3);
}
\fill[blue] (B2a) circle(2pt);
\end{scope}
\node[anchor=north west] at (A) {9-graph};
\node at (B) {4-graph};
\node at (C) {5-graph};
\end{tikzpicture}
它从圆 B 画出一些线到圆 A 中的点。我不确定如何才能将这些线画到圆 C 内的点。有人知道我该怎么做吗?
并实现
\coordinate (A1a) at ($(A)+(-20:\aeRadiusA*0.75)$);
\coordinate (C1a) at ($(C)+(90+20:\aeRadiusC*0.75)$);
\coordinate (A1b) at ($(A1a)+(3pt,2pt)$);
\coordinate (C1b) at ($(C1a)+(0pt,-2pt)$);
\coordinate (C1c) at ($(C1b)+(5pt,-2pt)$);
\coordinate (C1d) at ($(C1c)+(10pt,8pt)$);
\coordinate (C1e) at ($(C1d)+(10pt,8pt)$);
\coordinate (C1f) at ($(C1e)+(-5pt,-2pt)$);
\coordinate (C1g) at ($(C1e)+(-45pt,-20pt)$);
\coordinate (A2a) at ($(A)+(30:\aeRadiusA*0.65)$);
\coordinate (B2a) at ($(B)+(140:\aeRadiusB*0.65)$);
\coordinate (A2b) at ($(A2a)+(15pt,4pt)$);
\coordinate (B2b) at ($(B2a)+(-4pt,3pt)$);
\begin{scope}[rotate=100]
\fill[red!20] (B2a) circle (4pt);
\draw[blue] (B2a) -- (C1a);
\draw[red] (B2a) -- (C1b);
\draw[blue] (B2a) -- (C1c);
\draw[red] (B2a) -- (C1d);
\draw[blue] (B2a) -- (C1e);
\draw[red] (B2a) -- (C1f);
\draw[blue] (B2a) -- (C1g);
\fill[red] (B2a) circle(2pt);
\end{scope}
正如您所看到的,这些行是硬编码的,不是我想要的。
答案1
如果只是用两种交替的颜色从一个固定点到多个其他点绘制线条,则可以执行以下操作:
\documentclass[tikz, border=5mm]{standalone}
\begin{document}
\begin{tikzpicture}
\foreach [count=\i] \x in {a,...,g} {
% use a mod() for swapping between red and blue
\pgfmathparse{mod(\i, 2) ? "red" : "blue"}
% draw from fixed point to point in foreach with color determined by mod()
\draw [\pgfmathresult] (B2a) -- (C1\x);
}
\end{tikzpicture}
\end{document}