1

I am trying to create some tikz figures for to illustrate different earth reference frames. The code I am using is inspired by this:

\tdplotsetmaincoords{60}{110}
%
\pgfmathsetmacro{\rvec}{.8}
\pgfmathsetmacro{\thetavec}{45}
\pgfmathsetmacro{\phivec}{50}
%
\definecolor{darkgreen}{rgb}{0.1,0.7,0.1}

\begin{tikzpicture}[scale=5,tdplot_main_coords]
\coordinate (O) at (0,0,0);
\draw[thick,->] (0,0,0) -- (1,0,0) node[anchor=north east]{$X{\text{ecef}}$};
\draw[thick,->] (0,0,0) -- (0,1,0) node[anchor=north west]{$Y_{\text{ecef}}$};
\draw[thick,->] (0,0,0) -- (0,0,1) node[anchor=south]{$Z_{\text{ecef}}$};

\tdplotsetcoord{P}{\rvec}{\thetavec}{\phivec}
\tdplotdrawarc[blue]{(O)}{0.8}{-90}{90}{}{}
\tdplotdrawarc[dashed,blue]{(O)}{0.8}{90}{270}{}{}
%
\tdplotsetthetaplanecoords{\phivec}
%
\tdplotsetthetaplanecoords{0}
\tdplotdrawarc[tdplot_rotated_coords]{(0,0,0)}{0.8}{0}{90}{left}{\rotatebox[origin=cc]{85}{Prime Meridian}}
\tdplotdrawarc[tdplot_rotated_coords]{(0,0,0)}{0.8}{90}{180}{}{}
%
\tdplotsetthetaplanecoords{90}
\tdplotdrawarc[tdplot_rotated_coords,blue]{(0,0,0)}{0.8}
{0}{360}{}{}
%
\end{tikzpicture}

If I set my maincoords to {75}{95} it looks like

and apart from the weird thing where the prime meridian and the south pole meet it looks fine.

The x axis is a little too "out of the screen" for my liking, but when I use {60}{110} it looks like

where the intersections just look kind of wrong. Maybe I my expectation is wrong but this viewing angle looks like a very warped circle which wasn't really what I had expected. Especially given that the tikz is written with respect to rotation and reference frames so I figure that shouldn't change much with different viewing angles.

I'm not quite sure what is wrong or if I have misguided expectations, but I am trying to fix this such that the latter viewing angle doesn't show such a warped looking sphere.

1 Answers1

2

Here is an example using the inofficial circleofsphere package.

\documentclass[tikz,border=3mm]{standalone}
\usepackage{tikz-3dplot-circleofsphere}

\begin{document}
\definecolor{darkgreen}{rgb}{0.1,0.7,0.1}
\tdplotsetmaincoords{60}{110}
\begin{tikzpicture}[scale=5,tdplot_main_coords,thick,>=stealth]
 %
 \pgfmathsetmacro{\rvec}{.8}
 \pgfmathsetmacro{\thetavec}{45}
 \pgfmathsetmacro{\phivec}{50}
 %
 \coordinate (O) at (0,0,0);
 \draw (O) -- (\rvec,0,0);
 \draw (O) -- (0,\rvec,0);
 \draw (O) -- (0,0,\rvec);
 \path[tdplot_screen_coords,ball color=gray,opacity=0.9] (O) circle[radius=\rvec];
 \begin{scope}[blue]
   \tdplotCsDrawLatCircle{\rvec}{0}
   \tdplotCsDrawLonCircle{\rvec}{90}
 \end{scope}  
 \draw[thick,->] (\rvec,0,0) -- (1,0,0) node[anchor=north east]{$X_\mathrm{ecef}$};
 \draw[thick,->] (0,\rvec,0) -- (0,1,0) node[anchor=north west]{$Y_\mathrm{ecef}$};
 \draw[thick,->] (0,0,\rvec) -- (0,0,1) node[anchor=south]{$Z_\mathrm{ecef}$};
 %
\end{tikzpicture}
\end{document}

enter image description here

If you wish to annotate these arcs, I recommend decorations.text.

\documentclass[tikz,border=3mm]{standalone}
\usepackage{tikz-3dplot-circleofsphere}
\usetikzlibrary{decorations.text}
\begin{document}
\definecolor{darkgreen}{rgb}{0.1,0.7,0.1}
\tdplotsetmaincoords{60}{110}
\begin{tikzpicture}[scale=5,tdplot_main_coords,thick,>=stealth]
 %
 \pgfmathsetmacro{\rvec}{.8}
 \pgfmathsetmacro{\thetavec}{45}
 \pgfmathsetmacro{\phivec}{50}
 %
 \coordinate (O) at (0,0,0);
 \draw (O) -- (\rvec,0,0);
 \draw (O) -- (0,\rvec,0);
 \draw (O) -- (0,0,\rvec);
 \begin{scope}[blue,tdplotCsFront/.style={draw=none}]
   \tdplotCsDrawLatCircle{\rvec}{0}
   \tdplotCsDrawLonCircle{\rvec}{90} 
 \end{scope}  
 \path[tdplot_screen_coords,ball color=gray,opacity=0.9] (O) circle[radius=\rvec];
 \begin{scope}[blue,tdplotCsBack/.style={draw=none}]
   \tdplotCsDrawLatCircle{\rvec}{0}
   \tdplotCsDrawLonCircle{\rvec}{90}
   \draw[decoration={text along path,text={|\sffamily\large\color{blue}|Equator},raise=3pt},
    decorate]  plot[variable=\t,domain=10:80]
     ({\rvec*cos(\t)},{\rvec*sin(\t)},0);
   \draw[decoration={text along path,text={|\sffamily\large\color{blue}|Prime Meridian},raise=3pt},
    decorate]  plot[variable=\t,domain=10:80]
     ({\rvec*cos(\t)},0,{\rvec*sin(\t)});
 \end{scope}  
 \draw[thick,->] (\rvec,0,0) -- (1,0,0) node[anchor=north east]{$X_\mathrm{ecef}$};
 \draw[thick,->] (0,\rvec,0) -- (0,1,0) node[anchor=north west]{$Y_\mathrm{ecef}$};
 \draw[thick,->] (0,0,\rvec) -- (0,0,1) node[anchor=south]{$Z_\mathrm{ecef}$};
 %
\end{tikzpicture}
\end{document}

enter image description here

  • as a followup is there an easy way to label one of the lat/long circles? For example putting a lable in the positive XY plane along the rim of the lat circle that says "Equator"? – Morten Nissov Dec 21 '19 at 21:48
  • @MortenNissov This is very easy. Do you need the text follow the path? –  Dec 21 '19 at 21:54
  • Yes sure, I'm not super familiar with tikz so I just need a kickstart on the syntax. I can try and play around with formatting it on my own.

    Also, shouldn't the the transition of the longitude circle from solid to dashed intersect with the z axis? Did I word that understandably?

    – Morten Nissov Dec 21 '19 at 22:05
  • @MortenNissov Please have a look at the update. –  Dec 21 '19 at 22:08
  • @MortenNissov No, it shouldn't intersect for your choice of view angles. You look at the sphere from an angle, and thus see the north pole but not the south pole. Imagine you'd look from the top, then the north pole would be in the middle. If you want the transition of the longitude circle from solid to dashed intersect with the z axis, choose \tdplotsetmaincoords{89}{110} (for 90 degrees these views have problems but 89 degrees is a very good approximation). –  Dec 21 '19 at 22:17
  • Okay I see, that makes sense. Thank you so much. – Morten Nissov Dec 21 '19 at 22:18