# Arcs on 3D Sphere

I am trying to draw this with tikz:

So far I got this together:

My (awkward) code:

\documentclass[crop,tikz]{standalone}
\usepackage{tikz-3dplot}
\usepackage{marvosym}

\begin{document}
\tdplotsetmaincoords{70}{120}
\begin{tikzpicture}[tdplot_main_coords, scale=2]

% Earth
\tdplotsetrotatedcoords{20}{80}{0}
\draw [ball color=white,very thin,tdplot_rotated_coords] (0,0,0) circle (1) ;
% Equator
\draw [dashed] (0,0,0) circle (1) ;

% Axis
\draw[thick,->] (0,0,0) -- (3,0,0) node[anchor=north east]{\Aries};
\draw[thick, dashed, ->] (0,0,0) -- (0,0,1.5) node[anchor=south]{$N$};

% Omega
\pgfmathsetmacro{\bx}{1}
\pgfmathsetmacro{\by}{1}
\pgfmathsetmacro{\bz}{0}

\draw[thick] (0,0,0) -- (\bx,\by,\bz) node[anchor=north]{};

\tdplotdefinepoints(0,0,0)(1,0,0)(\bx,\by,\bz);
\tdplotdrawpolytopearc[red, thick]{0.5}{anchor=north}{$\Omega$}

\end{tikzpicture}
\end{document}


Currently I really struggle to add the other arcs, as the 2d circle really confuses me. What's the easiest way to draw arcs on the 'sphere'?

Just to give you a start. Practically everything has been done by Alain Matthes in this answer.

\documentclass[tikz,border=3mm]{standalone}
\usetikzlibrary{calc}
\tikzset{%
to path={%
($(\tikztostart)!-#1!(\tikztotarget)$)--($(\tikztotarget)!-#2!(\tikztostart)$)%
}

\tikzset{%
mark coordinate/.style={inner sep=0pt,outer sep=0pt,minimum size=2pt,
fill=black,circle}%
}

\newcommand\pgfmathsinandcos[3]{%
\pgfmathsetmacro#1{sin(#3)}%
\pgfmathsetmacro#2{cos(#3)}%
}
\newcommand\LongitudePlane[2][current plane]{%
\pgfmathsinandcos\sinEl\cosEl{\Elevation} % elevation
\pgfmathsinandcos\sint\cost{#2} % azimuth
\tikzset{#1/.estyle={cm={\cost,\sint*\sinEl,0,\cosEl,(0,0)}}}
}
\newcommand\LatitudePlane[2][current plane]{%
\pgfmathsinandcos\sinEl\cosEl{\Elevation} % elevation
\pgfmathsinandcos\sint\cost{#2} % latitude
\pgfmathsetmacro\ydelta{\cosEl*\sint}
\tikzset{#1/.estyle={cm={\cost,0,0,\cost*\sinEl,(0,\ydelta)}}} %
}
\newcommand\DrawLongitudeCircle[1]{
\LongitudePlane{#1}
\tikzset{current plane/.prefix style={scale=\R}}
\pgfmathsetmacro\angVis{atan(sin(#1)*cos(\Elevation)/sin(\Elevation))} %
\draw[current plane,thin,black]  (\angVis:1)     arc (\angVis:\angVis+180:1);
\draw[current plane,thin,dashed] (\angVis-180:1) arc (\angVis-180:\angVis:1);
}%

\newcommand\DrawLatitudeCircle[1]{
\LatitudePlane{#1}
\tikzset{current plane/.prefix style={scale=\R}}
\pgfmathsetmacro\sinVis{sin(#1)/cos(#1)*sin(\Elevation)/cos(\Elevation)}
\pgfmathsetmacro\angVis{asin(min(1,max(\sinVis,-1)))}
\draw[current plane,thin,black] (\angVis:1) arc (\angVis:-\angVis-180:1);
\draw[current plane,thin,dashed] (180-\angVis:1) arc (180-\angVis:\angVis:1);
}%

\newcommand\DrawPointOnSphere[3]{%
\pgfmathsinandcos\sinLoM\cosLoM{#1}
\pgfmathsinandcos\sinLaM\cosLaM{#2}
}

\begin{document}
\begin{tikzpicture}
\def\Elevation{15} % elevation angle
\def\angleLongitudeP{-110} % longitude of point P
\def\angleLongitudeQ{-45} % longitude of point Q
\def\angleLatitudeQ{30} % latitude  Q    ; 0 latitude of P
\def\angleLongitudeA{-20} % longitude of point A

\pgfmathsetmacro\H{\R*cos(\Elevation)} % distance to north pole
\LongitudePlane[PLongitudePlane]{\angleLongitudeP}
\LongitudePlane[QLongitudePlane]{\angleLongitudeQ}
\LongitudePlane[ALongitudePlane]{\angleLongitudeA}
\LatitudePlane[Equator]{0}

\fill[ball color=white!10] (0,0) circle (\R); % 3D lighting effect
\coordinate (O) at (0,0);
\coordinate[] (N) at (0,\H);
\coordinate[] (S) at (0,-\H);

%setup coordinates P and Q
\path[ALongitudePlane] (0:\R) coordinate (A);
\path[ALongitudePlane] (32.5:\R) coordinate (A');
\path[ALongitudePlane] (122.5:\R) coordinate (N');
\path[PLongitudePlane] (0:\R) coordinate (P);
\path[QLongitudePlane] (\angleLatitudeQ:\R) coordinate (Q);
\path[QLongitudePlane] (0:\R) coordinate (B);
\draw [dashed] (O) --  (N) ;

\foreach \v in {N} {\coordinate[mark coordinate] (\v) at (\v);
\node [above] at (\v) {\v};}
\begin{scope}[ x={(P)}, y={(A')}, z={(N')}]
\draw[very thick,blue] ( -60:1) arc (-60:120:1) ;
\draw[very thick,blue,-latex] ( -60:1) arc (-60:60:1) ;
\end{scope}
\draw[red,very thick,Equator] (180:\R) arc (180:360:\R);

\end{tikzpicture}
\end{document}


UPDATE: Some minor additions were made in this post. With those you could do:

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

\newcommand\pgfmathsinandcos[3]{%
\pgfmathsetmacro#1{sin(#3)}%
\pgfmathsetmacro#2{cos(#3)}%
}
\newcommand\LongitudePlane[3][current plane]{%
\pgfmathsinandcos\sinEl\cosEl{#2} % elevation
\pgfmathsinandcos\sint\cost{#3} % azimuth
\tikzset{#1/.style={cm={\cost,\sint*\sinEl,0,\cosEl,(0,0)}}}
}

\newcommand\LatitudePlane[3][current plane]{%
\pgfmathsinandcos\sinEl\cosEl{#2} % elevation
\pgfmathsinandcos\sint\cost{#3} % latitude
\tikzset{#1/.style={cm={\cost,0,0,\cost*\sinEl,(0,\yshift)}}} %
}
\newcommand\NewLatitudePlane[4][current plane]{%
\pgfmathsinandcos\sinEl\cosEl{#3} % elevation
\pgfmathsinandcos\sint\cost{#4} % latitude
\pgfmathsetmacro\yshift{#2*\cosEl*\sint}
\tikzset{#1/.style={cm={\cost,0,0,\cost*\sinEl,(0,\yshift)}}} %
}
\newcommand\DrawLongitudeCircle[2][1]{
\LongitudePlane{\angEl}{#2}
\tikzset{current plane/.prefix style={scale=#1}}
% angle of "visibility"
\pgfmathsetmacro\angVis{atan(sin(#2)*cos(\angEl)/sin(\angEl))} %
\draw[current plane] (\angVis:1) arc (\angVis:\angVis+180:1);
\draw[current plane,opacity=0.4] (\angVis-180:1) arc (\angVis-180:\angVis:1);
}
\newcommand\DrawLongitudeArc[4][black]{
\LongitudePlane{\angEl}{#2}
\tikzset{current plane/.prefix style={scale=1}}
\pgfmathsetmacro\angVis{atan(sin(#2)*cos(\angEl)/sin(\angEl))} %
\pgfmathsetmacro\angA{mod(max(\angVis,#3),360)} %
\pgfmathsetmacro\angB{mod(min(\angVis+180,#4),360} %
}%
\newcommand\DrawLatitudeCircle[2][1]{
\LatitudePlane{\angEl}{#2}
\tikzset{current plane/.prefix style={scale=#1}}
\pgfmathsetmacro\sinVis{sin(#2)/cos(#2)*sin(\angEl)/cos(\angEl)}
% angle of "visibility"
\pgfmathsetmacro\angVis{asin(min(1,max(\sinVis,-1)))}
\draw[current plane] (\angVis:1) arc (\angVis:-\angVis-180:1);
\draw[current plane,opacity=0.4] (180-\angVis:1) arc (180-\angVis:\angVis:1);
}

\newcommand\DrawLatitudeArc[4][black]{
\LatitudePlane{\angEl}{#2}
\tikzset{current plane/.prefix style={scale=1}}
\pgfmathsetmacro\sinVis{sin(#2)/cos(#2)*sin(\angEl)/cos(\angEl)}
% angle of "visibility"
\pgfmathsetmacro\angVis{asin(min(1,max(\sinVis,-1)))}
\pgfmathsetmacro\angA{max(min(\angVis,#3),-\angVis-180)} %
\pgfmathsetmacro\angB{min(\angVis,#4)} %
}

%% document-wide tikz options and styles

\tikzset{%
>=latex, % option for nice arrows
inner sep=0pt,%
outer sep=2pt,%
mark coordinate/.style={inner sep=0pt,outer sep=0pt,minimum size=3pt,
fill=black,circle}%
}

\begin{document}

\begin{tikzpicture} % "THE GLOBE" showcase
\def\angEl{20} % elevation angle
\def\angAz{-20} % azimuth angle

\pgfmathsetmacro\H{\RadiusSphere*cos(\angEl)} % distance to north pole
\coordinate (O) at (0,0);
\node[circle,draw,black,scale=0.3] at (0,0) {};
\draw[right] node at (0,0){O};
\coordinate[mark coordinate] (N) at (0,\H);
\draw[left] node at (0,\H){N};
\coordinate[mark coordinate] (S) at (0,-\H);
\draw[left] node at (0,-\H){S};
\draw[thick, dashed, black](N)--(S);

\tikzset{
every path/.style={
color=green!50!black
}
}
\tikzset{
every path/.style={
color=black
}
}

%\draw[-,dashed] (Oprime) -- (O) -- (Pprime);

%%%%%%%%
\def\angleLongitudeP{-110} % longitude of point P
\def\angleLongitudeQ{-45} % longitude of point Q
\def\angleLatitudeQ{30} % latitude  Q    ; 0 latitude of P
\def\angleLongitudeA{-20} % longitude of point A

\LongitudePlane[PLongitudePlane]{\angleLongitudeP}{\angAz}
\LongitudePlane[QLongitudePlane]{\angleLongitudeQ}{\angAz}
\LongitudePlane[ALongitudePlane]{\angleLongitudeA}{\angAz}

\begin{scope}[ x={(P)}, y={(A')}, z={(N')}]
\draw[very thick,blue] (-135:0.75) arc (-135:45:0.75) ;
\draw[very thick,blue,-latex] (-135:0.75) arc (-135:-15:0.75) ;
\coordinate (Q) at (-60:0.75);
\end{scope}
\draw (Q) -- (O);
\draw[-latex] (O) -- (X) node[below]{$x$};
node[pos=0.7,above]{$\Omega$};

\end{tikzpicture}

\end{document}


NOTE: TikZ has no real 3D engine. So you need to do many things "by hand". And of course in 3 dimensions things are always a bit more tricky than in 2.

• Wow, thanks for your help! I won't have the time to look into it before tomorrow, but I'm going to come back to you in case I have any questions. Thank you very much. :-) – wheeler Apr 22 '18 at 19:09
• I had an extensive look at your code and the other answer, but I am still confused how you draw the arc. I understand that the intercept between both arcs is at point P. But how do I have to adjust the line \draw[very thick,blue] ( -60:1) arc (-60:120:1) after I changed the longitude of P? – wheeler Apr 23 '18 at 13:57
• @wheeler I added a second example, which is closer to your screenshot. I remember that I also had some problems with Alain Matthes original macros, basically because one could not adjust the "rotation angle" of the sphere. That's why I posted this minor modification. However, I do not remember what precisely these additions were, looking at them now I do not think that it was me who introduced the second angle, but I couldn't find it anywhere else either. – marmot Apr 23 '18 at 14:23
• Just one minor question concerning the notation of the arc definition. In the first brackets - e.g. (135:\arcrad) - are these the polar coordinates of the start? Or what's the difference to this notation: \draw (x,y) arc (start:stop:radius)? – wheeler Apr 23 '18 at 22:26
• @wheeler Yes, they are. You are switching to a plane and drawing arcs there. And yes, the TikZ arcs are a bit "arcward" in the sense that you need to specify the start twice, and you could use Cartesian coordinates as well, but wouldn't that make you compute sines and cosines? Just in case you do not know yet, there exists a much simpler tool for 3D drawings: Asymptote. It does all the projections for you. – marmot Apr 23 '18 at 22:45