I use the following code, inspired by Dario Orescanin, to draw a circle with helper lines, for Spirograph aligning purposes.

\frametitle{circle helper lines}
\vskip -.6cm
\draw [green](0,0) circle (\radius);
\node[draw, circle, black, line width=.1mm, inner sep=.01mm] (a) at (0,0) {.};
\foreach \x in {0,11.25,...,359}
\node[scale=.6, red] at (360+\x:\labelrad*1.36) {$\x^\circ$};
\draw [red,line width=.1mm] (a) -- (\x:\radius);
\foreach \x in {0,...,359}\draw[green,line width=.1mm] (\x:\onedegrad) -- (\x:\radius);

enter image description here

For a 4-side figure, I need lines every 11.25 angle, using the code

\foreach \x in {0,11.25,...,359}

For a 3-side figure, I need lines every 10 angle

For a 7-side figure, I need lines every 12.857 angle

and so on.

To simplify the needed calculations, is there a way to modify the used code to be

\foreach \x in {360/8/4*0, 360/8/4*1, ...,359}

\foreach \x in {360/3/3/4*0, 360/3/3/4*1, ...,359}

\foreach \x in {360/7/4*0, 360/7/4*1, ...,359}


This is not a complete answer since I really do not understand your prescription. There is a simple formula that covers the cases n=3,...,7, but perhaps not beyond:

  Delta alpha (n) = 15 -15/n .

If you kindly explain the logic of these graphs a bit more I am confident to be able to generalize it further.

Here is what I have so far. One only needs to adjust the formula to go beyond.

\tikzset{pics/helper lines/.style={code={
  \tikzset{helper lines/.cd,#1}
  \def\pv##1{\pgfkeysvalueof{/tikz/helper lines/##1}}
  \draw [green](0,0) node[ball color=gray,inner sep=1.5pt,circle,draw] (a){} circle[radius=\pv{r}];
  \foreach \XX in {0,\nextX,...,359}
  {\node[scale=.6, red,anchor=\XX+180] at (360+\XX:\pv{r}) {$\pgfmathprintnumber{\XX}^\circ$};
  \draw [red,line width=.1mm] (a) -- (\XX:\pv{r});
  \foreach \XX in {0,...,359}
  {\draw[green,line width=.1mm] (\XX:\pv{dr}) -- (\XX:\pv{r});}
helper lines/.cd,r/.initial=2cm,dr/.initial=1.88cm,n/.initial=3}
\foreach \X in {3,4,...,7}
\frametitle{Circle helper lines: $n=\X$}
\pic[scale=1.8] {helper lines={n=\X}};

enter image description here

| improve this answer | |
  • @ Schrödinger's cat I want helper lines to align rotated patterns correctly. When I use, for example, an 8-side pattern as in i.stack.imgur.com/1XiUd.png, I calculate the exact rotation angle by using the equation 360/8/4 which gives 11.25. When trying to rotate a 23-side pattern, to make the uppermost spike vertical, I have to make several attempts to get the right rotation angle. So I need helper lines with 360/23/4 angles to get the correct needed rotation angle instead of doing several calculations to get it. That is why I need to use this equation in the foreach loop. – Hany Feb 7 at 14:13
  • @ Schrödinger's cat. That is why I need to use 360/23/4 equation inside the \foreach loop: \foreach \x in {360/23/4 *0, 360/23/4*1,360/23/4*2} and so on. – Hany Feb 7 at 14:22

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.