2

My problem is related to How to draw an arrow in the middle of the line of a circle and how to position the arrow? and How to draw various tangent circles in a circle?

I am attempting to draw 8 tangent circles, in a circle, with two labeled arrows on each circle positioned halfway around from each other such that the arrows rotate with the position of the circle.

My code:

\documentclass[crop,tikz]{standalone}

\usetikzlibrary{decorations.markings}

\begin{document}

\begin{tikzpicture}[scale=0.6]
\foreach \i in {22.5,67.5,...,352.5}{
    \draw[
    decoration={markings,
    mark=at position {(\i)/360} with {\arrow{>}},
    mark=at position {(\i - 180)/360} with {\arrow{>}}},
    postaction={decorate}
    ]
    (\i:3.4) circle (1.3);
}
\foreach \a in {1,2,3,4}{
    \draw (\a*360/4 + 22.5: 5.1cm) node{$a$};
    \draw (\a*360/4 + 22.5: 1.7cm) node{$a$};
    \draw (\a*360/4 + 67.5: 5.1cm) node{$b$};
    \draw (\a*360/4 + 67.5: 1.7cm) node{$b$};
}
\filldraw[black] (0,3.14) circle (2pt) {};

\end{tikzpicture}

\end{document}

Which produces this image:

8 Circles in a Cirlce

As you can see, four of the arrows for the bottom four circles are misplaced. The cause of this misplacement being this line of code:

mark=at position {(\i - 180)/360} with {\arrow{>}}}

From what I understand, the position is supposed to be given within the range [0,1], but for some reason the negative values do not cause any issues. It isn't until the position becomes positive where the arrows become misplaced. Any ideas on how to fix this? Thanks for any help.

user3213847
  • 123
  • 3

2 Answers2

4

Welcome! Interestingly there can be situations in which rotating a circle around its center can make a difference. That is, instead computing the positions (e.g. with mod the problem can be solve) one can just rotate the circles. The markings get rotated as well.

\documentclass[crop,tikz]{standalone}

\usetikzlibrary{decorations.markings}

\begin{document}

\begin{tikzpicture}[scale=0.6]
\foreach \i in {0,45,...,315}{
    \draw[ rotate around={22.5+\i:(22.5+\i:3.4)},
    decoration={markings,
    mark=at position {0} with {\arrow{>}},
    mark=at position {0.5} with {\arrow{>}}},
    postaction={decorate}
    ]
     (22.5+\i:3.4)  circle [radius=1.3];
}
\foreach \a in {1,2,3,4}{
    \draw (\a*360/4 + 22.5: 5.1cm) node{$a$};
    \draw (\a*360/4 + 22.5: 1.7cm) node{$a$};
    \draw (\a*360/4 + 67.5: 5.1cm) node{$b$};
    \draw (\a*360/4 + 67.5: 1.7cm) node{$b$};
}
\filldraw[black] (0,3.14) circle [radius=2pt] {};

\end{tikzpicture}

\end{document}

enter image description here

And, oddly enough, an \ifodd allows you to condense it to one loop.

\documentclass[crop,tikz]{standalone}

\usetikzlibrary{decorations.markings}

\begin{document}

\begin{tikzpicture}[scale=0.6,>=stealth]
\foreach \X in {0,1,...,7}{
    \draw[ rotate around={22.5+\X*45:(22.5+\X*45:3.4)},
    decoration={markings,
    mark=at position {0} with {\arrow{>}},
    mark=at position {0.5} with {\arrow{>}}},
    postaction={decorate}
    ]
     (22.5+\X*45:3.4)  circle [radius=1.3];
    \path (22.5+\X*45:1.7) node{$\ifodd\X b\else a\fi$}
    (22.5+\X*45:5.1) node{$\ifodd\X b\else a\fi$};
}
\filldraw[black] (0,3.14) circle [radius=2pt] {};

\end{tikzpicture}

\end{document}

And one can shorten further and further,

\documentclass[crop,tikz]{standalone}

\usetikzlibrary{decorations.markings}

\begin{document}

\begin{tikzpicture}[scale=0.6,>=stealth]
\foreach \X in {0,1,...,7}{
    \draw[rotate={22.5+\X*45},
    decoration={markings,
    mark=at position {0} with {\arrow{>}},
    mark=at position {0.5} with {\arrow{>}}},
    postaction={decorate}]
     (0:3.4)  circle [radius=1.3] (0:1.7) node{$\ifodd\X b\else a\fi$}
    (0:5.1) node{$\ifodd\X b\else a\fi$};
}
\filldraw[black] (0,3.14) circle [radius=2pt] {};

\end{tikzpicture}

\end{document}

Or with bent arrows and without decorations.

\documentclass[crop,tikz]{standalone}

\usetikzlibrary{arrows.meta,bending}

\begin{document}

\begin{tikzpicture}[scale=0.6,>={Stealth[bend]}]
\foreach \X in {0,1,...,7}{\begin{scope}[rotate={22.5+\X*45}]
    \draw[->]
     (0:3.4-1.3) arc[start angle=180,end angle=368,radius=1.3];
    \draw[->]
     (0:3.4+1.3) arc[start angle=00,end angle=188,radius=1.3];
    \path (0:3.4)  circle [radius=1.3] (0:1.7) node{$\ifodd\X b\else a\fi$}
    (0:5.1) node{$\ifodd\X b\else a\fi$};
    \end{scope}
}
\filldraw[black] (0,3.14) circle [radius=2pt] {};

\end{tikzpicture}

\end{document}

enter image description here

And yes, one can use chains here....

1
size(300);
unitsize(1cm);
real distance=3.4,radius=1.3;
real Angle[];
pair z[];
path PATH[];
for (int i=0; i<360; i=i+45){
  Angle.push(i);
  z.push(distance*dir(22.5+i));
}
string st[]={"$a$","$b$"};
st.cyclic=true;
for (int i=0; i<z.length; ++i){
  PATH.push(rotate(22.5+Angle[i],z[i])*circle(z[i],radius));
  draw(PATH[i],ArcArrow(Fill(black),Relative(0.5)));
  draw(PATH[i],invisible,EndArcArrow(Fill(black)));
  label(Label(st[i],Relative(0.5)),PATH[i]);
  label(Label(st[i],align=RightSide,Relative(1)),PATH[i]);
}
dot((0,3.14));

enter image description here