7

I am trying to draw geodesics on a sphere. While many approaches, like for example this one, i am more interested in another way. If i specify two points, say qand p on the Sphere, i would like to join them by a geodesic, i.e. arc. Whether thats the longer or shorter arc, might be a problem for further stuff, i managed to do the following

\documentclass[a4paper]{standalone} \usepackage{tikz,tikz-3dplot} \tikzstyle{point}=[inner sep=0pt, outer sep=0pt,% minimum size=2pt,fill=black,shape=circle] \begin{document} \tdplotsetmaincoords{70}{110} \begin{tikzpicture} \begin{scope}[tdplot_main_coords] %draw sphere \tdplotsphericalsurfaceplot{72}{36}{1}{black!75!white}{blue!20!white}% {\draw[color=black,thick,->] (1,0,0) -- (1.5,0,0) node[anchor=north east]{$x$};}% {\draw[color=black,thick,->] (0,1,0) -- (0,1.5,0) node[anchor=north west]{$y$};}% {\draw[color=black,thick,->] (0,0,1) -- (0,0,1.5) node[anchor=south]{$z$};}% % draw geodesics \tdplotdefinepoints(0,0,0)(0.7071,-0.7071,0)(0,0.7071,0.7071) \tdplotdrawpolytopearc[thick,red!50!black]{1}{}{} \tdplotdefinepoints(0,0,0)(0.7071,-0.7071,0)(0.7071,0.7071,0) \tdplotdrawpolytopearc[thick,blue!50!black]{1}{}{} \tdplotdefinepoints(0,0,0)(0.7071,0.7071,0)(0,0.7071,0.7071) \tdplotdrawpolytopearc[thick,green!50!black]{1}{}{} %draw point \tdplotsetcoord{P}{1}{30}{60} \node[point,label={0:\(p\)}] at (P) {}; \end{scope} \end{tikzpicture} \end{document} 

which yields

an MWE not a beauty

and leads me to my two questions:

1) I would like to be able to specify both “spanning” points (the second and third of \tdplotdefinepoints in polar coordinates. It would be enough, to have a function performing theta,phi into px,py,pz, similar to the function used for the point P. Or maybe one could also kind of extract these coordinates from a label; is either of that possible?

2) when drawing an arc, is there a possibility – similar to the usual \draw to access the mid point? It would be enough to be able to place a node (with style) and label there, otherwhise a \coordinate would of course do the job, too. Any ideas on how to get that?

2
  • Would you be interested in a solution that is entirely based on spherical coordinates? (IMHO it does not no make too much sense to use cartesian coordinates to parametrize points on the surface of a sphere.) Commented Dec 30, 2018 at 0:22
  • In most of my calculations its easier to have cartesian coordinates, since for geodesics (great arcs) you would have to calculate several modulo cases in spherical coordinates; tangent vectors are cartesian anyways. However, I would be interested in any solution :) Commented Jan 4, 2019 at 7:52

1 Answer 1

2

This is at best 50% of an answer because I simply do not understand the first request. \tdplotsetcoord{P}{1}{30}{60} does define a point in 3d. Could you please rephrase the first request?

The second point is straightforward. decorations.markings allows you to mark a point at any position of the path, of course including the middle. The style add coordinate={<name> at <pos>} does that in the following MWE.

\documentclass[a4paper]{standalone} \usepackage{tikz,tikz-3dplot} \usetikzlibrary{decorations.markings} \tikzset{point/.style={inner sep=0pt, outer sep=0pt,% minimum size=2pt,fill=black,shape=circle}, add coordinate/.style args={#1 at #2}{postaction={decorate, decoration={markings,mark=at position #2 with {\coordinate (#1);}}}}} \begin{document} \tdplotsetmaincoords{70}{110} \begin{tikzpicture} \begin{scope}[tdplot_main_coords] %draw sphere \tdplotsphericalsurfaceplot{72}{36}{1}{black!75!white}{blue!20!white}% {\draw[color=black,thick,->] (1,0,0) -- (1.5,0,0) node[anchor=north east]{$x$};}% {\draw[color=black,thick,->] (0,1,0) -- (0,1.5,0) node[anchor=north west]{$y$};}% {\draw[color=black,thick,->] (0,0,1) -- (0,0,1.5) node[anchor=south]{$z$};}% % draw geodesics \tdplotdefinepoints(0,0,0)(0.7071,-0.7071,0)(0,0.7071,0.7071) \tdplotdrawpolytopearc[thick,red!50!black,add coordinate={M1 at 0.5}]{1}{}{} \tdplotdefinepoints(0,0,0)(0.7071,-0.7071,0)(0.7071,0.7071,0) \tdplotdrawpolytopearc[thick,blue!50!black,add coordinate={M2 at 0.5}]{1}{}{} \tdplotdefinepoints(0,0,0)(0.7071,0.7071,0)(0,0.7071,0.7071) \tdplotdrawpolytopearc[thick,green!50!black,add coordinate={M3 at 0.5}]{1}{}{} %draw point \tdplotsetcoord{P}{1}{30}{60} \node[point,label={0:\(p\)}] at (P) {}; \node[point,label={90:{$M_1$}}] at (M1){}; \node[point,label={-90:{$M_2$}}] at (M2){}; \node[point,label={0:{$M_3$}}] at (M3){}; \end{scope} \end{tikzpicture} \end{document} 

enter image description here

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.