8

I am attempting to draw the plot of an epicycloid. The formula (which looks nicer compiled):

  x = (a+b)\cos{}\phi{}-b\cos{}\left(\frac{a+b}{b}\phi{}\right)
  y = (a+b)\sin{}\phi{}-b\sin{}\left(\frac{a+b}{b}\phi{}\right)

enter image description here

I do not want to draw the full epicycloid around the perimeter of the larger circle ; rather, I'd like to start the path where the two circles are on the x-axis and proceed through about 50 degrees (ish).

The full version is more robust. For example, the length of the axes adjust to the size of the circles and the angle phi. There are numerous other lines and nodes in the figure. All of these have been eliminated to achieve a concise MWE:

\documentclass{article}

\usepackage{mathtools}
\usepackage{tikz}
\usetikzlibrary{calc,intersections}

\begin{document}
\begin{figure}[!htb]\centering{}
\begin{tikzpicture}[scale=1.0]

  \newcommand*{\angA}{25}
  \newcommand*{\rA}{2.0}
  \newcommand*{\rB}{1.0}

  % define the equations for P(x,y)
  \pgfmathsetmacro{\epicycloidX}%
    {((\rA+\rB)*cos(\angA))-(\rB*cos((\rA+\rB)/(\rB)*\angA))}
  \pgfmathsetmacro{\epicycloidY}%
    {((\rA+\rB)*sin(\angA))-(\rB*sin((\rA+\rB)/(\rB)*\angA))}

  \coordinate (O) at (0,0);
  \coordinate (P) at (\epicycloidX,\epicycloidY);
  \coordinate (F) at ({(\rA+\rB)*cos(\angA)},{(\rA+\rB)*sin(\angA)});
  
  \draw (-5, 0) -- (5,0);           % x-axis
  \draw ( 0,-5) -- (0,5);           % y-axis
  \draw ( 0, 0) circle (\rA);       % circle A at origin
  \draw (F) circle (\rB);           % circle B
  \draw (O) -- (F);                 % show the angle phi
  
  % code that does not do as expected. it compiles fine.
  \draw[blue,thick,domain=0*pi:0.3*pi,]
       plot[smooth]
       (
       {((\rA+\rB)*cos(\x ))-(\rB*cos(\x ((\rA+\rB)/\rB)))},
       {((\rA+\rB)*sin(\x ))-(\rB*sin(\x ((\rA+\rB)/\rB)))}
       );
  
  % draw the point P and label the node. this plots correctly.
  \draw[magenta,fill=white,] 
       (P)  
       circle (2pt)
       node[above left]{$P$};

\end{tikzpicture}
\caption{The epicycloid around Circle A has been reported missing.}
\end{figure}
\end{document}

but it does nothing. What am I missing?

11
  • The argument of cos and sin is by default taken to be in degrees. To convert radians to degrees, add the letter r. In your example, you have to write e.g.

      {((\rA+\rB)*cos(\x r))-(\rB*cos(\x ((\rA+\rB)/\rB) r))},
                         ^                               ^
                        HERE                            HERE
    
  • There are multiplication signs missing (in both coordinates)

      {((\rA+\rB)*cos(\x r))-(\rB*cos(\x*((\rA+\rB)/\rB) r))},
                                        ^
                                      HERE
    

enter image description here

\documentclass{article}

\usepackage{mathtools}
\usepackage{tikz}
\usetikzlibrary{calc,intersections}

\begin{document}
\begin{figure}[!htb]\centering{}
\begin{tikzpicture}[scale=1.0]

  \newcommand*{\angA}{25}
  \newcommand*{\rA}{2.0}
  \newcommand*{\rB}{1.0}

  % define the equations for P(x,y)
  \pgfmathsetmacro{\epicycloidX}%
    {((\rA+\rB)*cos(\angA))-(\rB*cos((\rA+\rB)/(\rB)*\angA))}
  \pgfmathsetmacro{\epicycloidY}%
    {((\rA+\rB)*sin(\angA))-(\rB*sin((\rA+\rB)/(\rB)*\angA))}

  \coordinate (O) at (0,0);
  \coordinate (P) at (\epicycloidX,\epicycloidY);
  \coordinate (F) at ({(\rA+\rB)*cos(\angA)},{(\rA+\rB)*sin(\angA)});
  
  \draw (-5, 0) -- (5,0);           % x-axis
  \draw ( 0,-5) -- (0,5);           % y-axis
  \draw ( 0, 0) circle (\rA);       % circle A at origin
  \draw (F) circle (\rB);           % circle B
  \draw (O) -- (F);                 % show the angle phi
  
  % code that does not do as expected. it compiles fine.
  \draw[blue,thick,domain=0*pi:0.3*pi,]
       plot[smooth]
       (
       {((\rA+\rB)*cos(\x r))-(\rB*cos(\x*((\rA+\rB)/\rB) r))},
       {((\rA+\rB)*sin(\x r))-(\rB*sin(\x*((\rA+\rB)/\rB) r))}
       );
  
  % draw the point P and label the node. this plots correctly.
  \draw[magenta,fill=white,] 
       (P)  
       circle (2pt)
       node[above left]{$P$};

\end{tikzpicture}
\caption{The epicycloid around Circle A has been reported missing.}
\end{figure}
\end{document}

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.