We now have a basic understanding of how to draw 3D diagrams and begin to come to the initial reason I wanted to learn TikZ/PGF: to draw a spherical triangle on a sphere.

Spherical Triangles:

A spherical triangle is formed on the surface of a sphere by the intersection of three great circles.

 

Spherical triangle ABC formed on the surface of the sphere by three great circles.

 

Quoting Wikipedia… Vertices and angles at the vertices are denoted by the same upper case letters A, B and C.
The sides are denoted by lower-case letters a, b, c. On the unit sphere their lengths are numerically equal to the radian measure of the angles that the great circle arcs subtend at the centre (since the arc length, l = rθ).

 

A spherical triangle with vertices A, B, C on a unit sphere, where the sides of the triangle a, b, c equal the angles created by the great circle planes.

Similar to the sine and cosine laws of a regular triangle. The spherical triangle has its spherical sine and cosine laws:

 

And it’s companion equations:

 

The spherical sine law:

Ok, so how do we go about drawing our diagram?

Drawing a Sphere:

The code will be structured in a very similar way. We draw our horizontal lines of latitude at heights of R*sin(theta) and the radius of our circles will be R*cos(theta). We can then rotate about x for the view angle and then around y to draw the various longitudinal lines.

 

The issue now is that lines at the back of the sphere are becoming mixed with those on the visible side. In the example at the top of the page, the hidden lines are dotted. How do we go about doing that?

Latitudinal Lines:

Lets start by trying to break-up the circles that create the latitudinal lines: we’ll draw a solid arc for the visible side an a dotted one for the hidden:

  1. \begin{tikzpicture} [scale =4]
  2.      \def\phi{10};
  3.      \draw (0, 0) circle (1);
  4.      %Draw latitudinal lines
  5.      \foreach \latitude in {-80, -50, …, 80} {
  6.           \pgfmathsetmacro\verticaloffset{cos(\phi)*sin(\latitude)};
  7.           \pgfmathsetmacro\radius{cos(\latitude)};
  8.           \tikzset{xyplane/.estyle={cm={1, 0, 0, cos(90 + \phi), (0, \verticaloffset)}}}
  9.           \draw [xyplane] (\radius,0) arc (0:180:\radius);
  10.           \draw [xyplane, dashed] (\radius,0) arc (360:180:\radius);
  11.      }
  12. \end{tikzpicture}\\

This doesn’t look too bad, but if you have a keen eye a problem is noticeable. If we increase the view angle to say 50 degrees, this will exaggerate the effect: the lines above the equator become dotted too early, whilst the lines below are doted too late; clearly the view angle is changing which parts of the lines are visible.

So how do we determine which section of the latitudinal lines should be drawn as dotted and where they should be drawn as solid lines?
It turns out this derivation (I found) is quite lengthy… but here goes:

In the figure below the great circle passing through D, C and B has been rotated $\psi$ from the north pole (from O to B) and has been rotated $\theta$ degrees (from A to D), the system has also been tilted by a viewing angle of $\phi$.
We need to find the length of the arc DC with respect to these angles.

 

We start with $\Delta$ABD and using the spherical sine law obtain:
 
 p, li { white-space: pre-wrap; } Using the sine rule on $\Delta$ABC gives:
We now have $x’$ in terms of ($\theta$, $\phi$, $\psi$) and $x$. To remove $x$ a new construction is made; in the figure below E is placed such that NE is perpendicular to our great circle. This means that NE represents our rotation $\psi$.

p, li { white-space: pre-wrap; }

Yay! we have our equation for a generic great circle. We can simplify this equation for the longitudinal and latitudinal lines:
Longitudinal Lines:
Longitudinal lines always pass through the poles, which means that $\psi = 0$. Substituting into \ref{eq:cot.x’.generic} gives the simplified equation:
Lets see how this looks:

Yay!

Latitudinal Lines:

Now we need to draw the Latitudinal lines. These are always parallel to the equator
These can

References:

Advertisements