# TikZ Geodesics on various shapes

Hi, I would like to draw something like the image below using TikZ.

Image 1: cylinder with two initially parallel geodesics remaining parallel.

Image 2: a kind of deformed cone (whose edges are given by 1/r where r is the horizontal direction). In this case, two initially parallel geodesics will be focused towards each other. I really want the r direction to run from r=0 to r=infinity but this would mean the left hand circle would be infinitely big so perhaps we could start it at r=1 and label it as "r=0" anyway? I would also like to label the right hand point as r=infinity if possible.

Image 3: a cylinder that gets squashed in the middle and then recovers with two initially parallel geodesics evolving through it. In this case, the edges are given by (r^2+1/r^2)^0.5 and so we can see that at r=0 and r=infinity both circles should be infinite. As in Image 2, it would be good if we could draw these as finite size circles (same size as each other) but label them as r=0 and r=infinty anyway.

Thanks very much for your help.

• Your question leaves all the effort to our community, even typing the essentials of a TeX document such as \documentclass{}...\begin{document} etc. As it is, most of our users will be very reluctant to touch your question, and you are left to the mercy of our procrastination team who are very few in number and very picky about selecting questions. You can improve your question by adding a minimal working example (MWE) that more users can copy/paste onto their systems to work on. If no hero takes the challenge we might have to close your question. – Tom Bombadil Oct 15 '15 at 8:46
• Just solve the Geodesic equation ;-) – user31729 Oct 15 '15 at 10:42

Here a copy and paste solution. The code isn't the best, but should show how you can achieve the desired graphic.

For graphics and (3) I reused (2) by using the xscale option to shrink and invert.

The code could be prettied up by defining a \newcommand or pic environment to create the base-graphic, the adjustments could be made via arguments. So you could save the copy and paste and make the whole thing reusable.

\documentclass[tikz, border=5mm]{standalone}

\def\mydomain{4*pi}

\begin{document}
\begin{tikzpicture}
\begin{scope}
\begin{scope}[domain=0:\mydomain, samples=250, ultra thick]
\draw [red] plot (\x, {sin(\x r)});
\draw [blue] plot (\x, {cos(\x r)});
\end{scope}

\begin{scope}[ultra thick]
\draw (0,1) arc (90:450:.5cm and 1cm);
\draw (\mydomain,1) arc (90:-90:.5cm and 1cm);
\draw [dashed] (\mydomain,1) arc (90:270:.5cm and 1cm);
\foreach \pos in {-1,1} \draw (0,\pos) -- ++(\mydomain, 0);
\end{scope}
\end{scope}

%%%

\begin{scope}[yshift=-4cm, xscale=4]
\begin{scope}[domain=0:\mydomain/4, samples=250, ultra thick]
\draw [red] plot (\x, {e^(-\x) * sin(2*pi*\x r)});
\draw [blue] plot (\x, {e^(-\x) * cos(2*pi*\x r)});
\draw plot (\x, {e^(-\x)});
\draw plot (\x, {-e^(-\x)});
\end{scope}

\begin{scope}[ultra thick, xscale=.25]
\draw (0,1) arc (90:450:.5cm and 1cm);
\end{scope}
\end{scope}

%%%

\begin{scope}[yshift=-8cm, xscale=2]
\begin{scope}[domain=0:\mydomain/4, samples=250, ultra thick]
\draw [red] plot (\x, {e^(-\x) * sin(pi*\x r)});
\draw [blue] plot (\x, {e^(-\x) * cos(pi*\x r)});
\draw plot (\x, {e^(-\x)});
\draw plot (\x, {-e^(-\x)});
\end{scope}

\begin{scope}[domain=0:\mydomain/4, samples=250, ultra thick, xscale=-1, xshift=-pi*2cm, yscale=-1]
\draw [red] plot (\x, {e^(-\x) * sin(pi*\x r)});
\draw [blue, yscale=-1] plot (\x, {e^(-\x) * cos(pi*\x r)});
\draw plot (\x, {e^(-\x)});
\draw plot (\x, {-e^(-\x)});
\end{scope}

\begin{scope}[ultra thick, xscale=.25]
\draw (0,1) arc (90:450:.5cm and 1cm);
\draw (\mydomain*2,1) arc (90:-90:.5cm and 1cm);
\draw [dashed] (\mydomain*2,1) arc (90:270:.5cm and 1cm);
\end{scope}
\end{scope}

\begin{scope}[xshift=14cm, ultra thick, font=\Large]
\foreach [count=\i] \pos in {0,-4,-8} \node at (0,\pos) [circle, draw] {\textbf{\i}};
\end{scope}
\end{tikzpicture}
\end{document}


• Picture 2 is not correct - geodesics do not asymptote to the generating curve, they turn around when the radius gets small, corresponding to conservation of angular momentum (Clairaut's relation). Similar problems in picture 3... – Andrew Swann Oct 15 '15 at 11:02
• @Andrew Swann Thanks for your reply. I have looked up Clairaut's relation which states that the quantity r*sin(theta) must be constant along the geodesic where r is the distance to the generating surface and theta is the angle between the geodesic and the meridian. I see in figures 2&3 that r decreases and so sin(theta) must increase but since I don't know where the meridian is on these diagrams, I don't know what effect this will have? Can you explain why this would result in the geodesic turning around? By turning around do you mean going back to the LHS of the picture? Thanks – user11128 Oct 16 '15 at 9:22
• The meridians are the generating curves of the surface. If r gets small, then sin(theta) has to increase, eventually reaching 1 at which point the geodesic is tangent to the vertical circular cross-sections. I have a picture of such a geodesic on the final page of these slides – Andrew Swann Oct 16 '15 at 11:02
• @Andrew Swann Thanks again. I'm afraid I can't get your link to open properly? Why would this mean that the geodesic has to turn around? Surely at r=infinity, the circle is infinitely small but the generating surface is now "flat" and so theta=pi/2 i.e. sin(theta)=1 and so 1/r * sin(theta) = 0. Is it because 1/r * sin(theta) is not equal to 0 at other values of r that is the reason for the geodesic turning round? – user11128 Oct 16 '15 at 11:33
• r = infty the circle is infinitely large . The relation r sin theta = c constant, prevents the geodesic passing into regions where the circles with r < c – Andrew Swann Oct 16 '15 at 11:39