2

Spirograph patterns are plotted by a point in a "circular" wheel moving along a ring.

Is it possible to edit the Spirograph code from the answer to this question to use a non-circular inner wheel (for example an elliptical wheel) instead of the inner circular wheel). The next photo shows some of the non-cirular inner wheels used in the commercial Spirograph toy.

enter image description here

The left inner wheel produces these drawings

enter image description here

The following is the basic Spirograph code I am referring to from this question.

\documentclass{beamer}
\beamertemplatenavigationsymbolsempty
\usepackage{tikz}
\begin{document}
\tikzset{pics/spiro/.style={code={
\tikzset{spiro/.cd,#1}
\def\pv##1{\pgfkeysvalueof{/tikz/spiro/##1}} 
\draw[trig format=rad,pic actions]
 plot[variable=\t,domain=0:2*pi*\pv{nRotations}, samples=90*\pv{nRotations}+1, smooth cycle]
(
{(\pv{R}+\pv{r})*cos(\t)+\pv{p}*cos((\pv{R}+\pv{r})*\t/\pv{r})},
{(\pv{R}+\pv{r})*sin(\t)+\pv{p}*sin((\pv{R}+\pv{r})*\t/\pv{r})}
);
}},
spiro/.cd,R/.initial=6,r/.initial=-1.5,p/.initial=1,nRotations/.initial=1}
\begin{frame}[t] 
\frametitle{}
\begin{center}
\begin{tikzpicture}[line width=.4mm]
\pic[draw,blue,fill=blue!40,scale=.7]{spiro={R=6,r=-1.5,p=1.52}}; 
\end{tikzpicture} 
\end{center} 
\end{frame}
\end{document}

which produces this simple figure

enter image description here

Hany
  • 4,709
  • I think you might want to add a bit more information. The graph can be obtained by patching segments of the basic spiro graph together. Basically you need to draw n times a fraction 1/N of the basic graph. I am wondering in which form you want to specify the data. –  Jan 20 '20 at 16:40
  • @ Schrödinger's cat In your code you specified the path of a point inside a moving circle. Is there a way to edit the code so that the path of the point could be specified inside a moving oval shape! I have no mathematical background. So, I wonder can that be done. – Hany Jan 20 '20 at 17:12
  • @ Schrödinger's cat If I understand correctly, a circle has one axis, but an oval (ellipse) has 2 axes. So, in your code, point p inside the circle is moving with one relation to its centre represented by (r); but in an ellipse, its movement has 2 relations. If my understanding is right, you have to specify 2 (r)s. – Hany Jan 20 '20 at 17:30
  • To me it seems that these are not ovals, i.e. no ellipses, but segments of larger circles patched together. Please correct me if I am wrong. –  Jan 20 '20 at 22:03
  • @ Schrödinger's cat I can not argue with you; because, as I`ve said, I have no mathematical background. With your point of view, could it be done. I mean modifying the code to utilize these wheel types. Or could it be modified to use a point inside a moving ellipse instead of a circle. – Hany Jan 21 '20 at 04:22
  • I think one may obtain the depicted graphs much easier using decorations. –  Jan 21 '20 at 04:33

1 Answers1

1

Here is a proposal to get something of the sort.

\documentclass[tikz,border=3mm]{standalone}
\usetikzlibrary{decorations.pathmorphing}
\begin{document}
\begin{tikzpicture}
 \draw[decoration={coil,aspect=0.25,segment length=pi*1cm/10.75},decorate]
  (0,0) arc[start angle=-60,end angle=60,radius=3cm]
  arc[start angle=120,end angle=240,radius=3cm];
 \draw[decoration={coil,aspect=0.25,segment length=pi*0.75cm/10.75},decorate]
  (7,1) arc[start angle=-15,end angle=75,radius=3cm]
  arc[start angle=105,end angle=195,radius=3cm]
  arc[start angle=225,end angle=315,radius=3cm];
\end{tikzpicture}
\end{document}

enter image description here

I fully understand that this is not perfect. However, to create something better, one needs clear prescriptions. In the previous questions of yours on this subject, there was a clear prescription that yielded a smooth graph. Here I see some corners, and one can only smoothen it out in an unambiguous way if there is some prescription.

One proposal in this direction is

\documentclass[tikz,border=3mm]{standalone}
\begin{document}
\begin{tikzpicture}[pics/narcs/.style={code={
 \tikzset{spiro/.cd,#1}
 \def\pv##1{\pgfkeysvalueof{/tikz/spiro/##1}} 
\draw plot[variable=\t,trig format=rad,domain=0:{2*pi*0.99},smooth
cycle,samples=15*\pv{S}]
({\pv{R}*cos(\t/\pv{S}-pi/(\pv{S}*\pv{S})
    +(\pv{S}-1)*2*pi*int(\pv{S}*\t/(2*pi))/(\pv{S}*\pv{S}))
    -\pv{R}*cos(pi/4)*cos(2*pi*int(\pv{S}*\t/(2*pi))/\pv{S})},
 {\pv{R}*sin(\t/\pv{S}-pi/(\pv{S}*\pv{S})
 +(\pv{S}-1)*2*pi*int(\pv{S}*\t/(2*pi))/(\pv{S}*\pv{S}))
 -\pv{R}*cos(pi/4)*sin(2*pi*int(\pv{S}*\t/(2*pi))/\pv{S})});}},
 spiro/.cd,R/.initial=3,S/.initial=2]
 \path pic{narcs}  (5,0) pic{narcs={S=3}}
 (10,0) pic{narcs={S=4}};
\end{tikzpicture}
\end{document}

enter image description here

I keep it mainly for my own records.

  • @ Schrödinger's cat I did not mean to draw the ellipse. I meant using an inner ellipse instead of an inner circle to draw a Spirograph. – Hany Jan 21 '20 at 05:12
  • @Hany Yes, adding the cycloid or spiro graph is easy if one has the base curve. I understand that this is only the first step. But I do not know what you precisely want to achieve. –  Jan 21 '20 at 06:38
  • @ Schrödinger's cat Using an elliptical inner wheel instead of an inner circle gives interesting Spirograph patterns. I wonder if this is possible by editing your code! https://i.stack.imgur.com/DiBgv.jpg – Hany Jan 21 '20 at 07:42
  • @Hany Can you try to explain this in your question as precisely as possible. There are now three different options floating around: ovals, ellipses (which are some specific ovals) and the shapes depicted in your screen shot, which are no ovals but have kinks. Anyone answering this question would probably need to know what you are really after. –  Jan 22 '20 at 00:58
  • @ Schrödinger's cat I edited my question to clarify my need. – Hany Jan 22 '20 at 10:59