Spherical vector geometry
Geometric calculations on the surface of a sphere are often simpler using linear algebra than spherical trigonometry.
Figure 1 The cross product of two vectors
Vector Operations
The dot product and cross product vector operations are key to many geometric calculations on a the surface of a sphere:
- the dot product of two 3D vectors is proportional to the cosine of the angle between them
- and the cross product of two 3D vectors is a third vector, perpendicular to the plane of the input vectors whose length is proportional to the sine of the angle between the input vectors, see Figure 1.
Vector calculations are especially simple when unit vectors are used to represent points and poles on the surface of a sphere.
Symbols
The following symbols are used throughout this document.
| Symbol | Name | Description |
|---|---|---|
| \(\phi\) | Latitude | Latitude from the plane of the Equator, North positive |
| \(\lambda\) | Longitude | Longitude from the Greenwich Meridian, East positive |
| \(\alpha\) | Azimuth | Bearing clockwise from true North |
| \(\theta\) | Great Circle Distance | Great circle distance on the surface of the sphere |
| d | Euclidean Distance | Euclidean distance through the sphere |
| atd | Along Track Distance | The distance along a great circle arc |
| xtd | Cross Track Distance | The distance beside a great circle |
Note: there is a glossary
Points
Figure 2 A vector in ECEF Coordinates
A point on the surface of the Earth can be represented as a 3D vector in Earth Centred Earth Fixed (ECEF) coordinates, see Figure 2.
An ECEF vector \(\vec{v}\) for a point on a unit sphere at latitude \(\phi\) and longitude \(\lambda\) is:
\[ \vec{v} = \begin{bmatrix} x \cr y \cr z \end{bmatrix} = \begin{bmatrix} cos\phi cos \lambda \cr cos\phi sin \lambda \cr sin\phi \end{bmatrix} \]Eq 1
Latitude and longitude can be calculated from an ECEF vector as:
\[ \phi = atan2(p_z, \sqrt{p_x^2 + p_y^2}) \]Eq 2
\[ \lambda = atan2(p_y, p_x) \]Eq 3
Note: longitude, \(\lambda\) is undefined at the poles.
Great Circles
Figure 3 A great circle plane, axis and pole
A great circle is the shortest path between points over the surface of a sphere. It is analogous to a straight line on a planar surface.
A great circle on the surface of a sphere can be viewed as the circular intersection of a sphere and a plane passing through the sphere’s centre, see Figure 3.
Pole Vector
Figure 4 A great circle arc and pole between points a and b
The pole of a great circle is a normal vector of the plane with its origin at the centre of the sphere, see Figure 3.
A great circle has two antipodal poles which lie along the axis of the great circle, corresponding to opposing great circles.
A normal vector of a great circle arc can be calculated as the
cross product of arc end points: a and b, see Figure 4.
A unit pole vector of a great circle arc may be calculated by
normalizing the planes normal vector:
Eq 4
Note: if points \(\vec{a}\) and \(\vec{b}\) are too close (or too far apart) then their cross product may be too small to normalize.
A unit ECEF great circle pole vector from a position (\(\phi\), \(\lambda\)) and azimuth \(\alpha\) is:
\[ \vec{pole} = \begin{bmatrix} x \cr y \cr z \end{bmatrix} = \begin{bmatrix} sin \lambda cos\phi - sin\phi cos \lambda sin\alpha \cr - cos \lambda sin - sin\phi sin \lambda sin\alpha \cr cos \phi sin\alpha \end{bmatrix} \]Eq 5
where: \(\alpha\) is the azimuth, i.e. the bearing relative to True North.
Azimuth
The azimuth \(\alpha\) at a point \(\vec{p}\) on great circle defined by \(\vec{pole}\) is:
\[ \alpha = atan2(pole_z, perp(pole_{xy}, p_{xy})) \]Eq 6
where: perp is the perp product, i.e. the 2D cross product.
Distance
Figure 5 Euclidean and great circle distances between points a and b
Great Circle Distance
great circle distance is the shortest distance between points over the surface of a sphere, see \(\theta\) in Figure 5.
Euclidean distance
However, great circle distance is not the shortest distance between points; that is the Euclidean distance i.e. the length of the difference vector between the points, the line a - b in Figure 5.
\[ d_e = ||\vec{b} - \vec{a} || \]Eq 7
Figure 5 is a cross section through a sphere on the plane of a great circle. It shows that the Euclidean distance between points is the chord of an arc between the point vectors.
It is possible to calculate a great circle distance \(\theta\) from a Euclidean distance \(d_e\) using:
\[ \theta = 2 arcsin(d_e / 2) \]
Eq 8
and a Euclidean distance \(d_e\) from a great circle distance \(\theta\) using:
\[ d_e = 2 sin(\theta/2) \]Eq 9
Cross Track Distance (XTD)
Figure 6 Great circle cross track distance (xtd)
The dot product of a point and a great circle pole is the planar distance of the point from the plane of the great circle: \(d_p\).
It is the sine of the great circle cross track distance (xtd), see Figure 6:
Eq 10
Note: dot product is signed, so planar distance also determines which side of a great circle a point lies.
Arc Direction and Position
Figure 7 Direction vector of a pole and point
Direction Vector
The direction vector at a point on a great circle is the cross product of the pole and point vectors, see Figure 7:
\[ \vec{dir} = \vec{pole} \times \vec{a} \]Eq 11
Note: the direction vector does not require normalization since both pole and reference point vectors are orthogonal unit vectors.
Position Vector
The position vector of a point, a signed distance θ from a reference point
along a great circle is:
Eq 12
where: \(\vec{a}\) is the reference point, \(\vec{dir}\) is the direction vector at the reference point and \(\theta\) is the distance as an angle.
Sine Along Track Distance
The dot product of a point and its direction vector is the sine of the along track distance (atd):
Eq 13
Note: the along track distance above is signed, but it is only valid for points within a quarter circle of the reference point.
Along Track Distance (ATD)
Figure 8 A point projected onto the plane of a great circle
Projected Point
A point may be projected onto the plane of a great circle by subtracting the great circle pole vector multiplied by the dot product of the point and pole from the point vector, see Figure 8:
\[ \vec{p_{plane}} = \vec{p} - d_p\vec{pole} \]Eq 14
This point can then be normalized to lie on the great circle where its great circle distance from a reference point can be calculated as described above.
Figure 9 Great circle Arc along track distance (d)
Eq 15
Note: if the projected point is too small to normalize onto the great circle then the point will be very close to one of the great circle poles. In which case, the along track distance will be meaningless.
Great Circle Intersection
Figure 10 A pair of intersecting great circle arcs
A pair of great circles intersect at two points unless they are coincident i.e. they share the same axis; in which case they “intersect” everywhere around the sphere.
An intersection point of two great circles \(\vec{c}\) may be calculated by normalizing the cross product of their poles: \(\vec{a}\) and \(\vec{b}\):
\[ \vec{c} = {\vec{a} \times \vec{b} \over {|| \vec{a} \times \vec{b} ||} } \]Eq 16
Note: just as a great circle has two poles, their intersection has two points, antipodal to each other, see c and d in Figure 10.
Coincident Great Circles
If the cross product of the poles is too small to normalize then the great circles are coincident. Coincident great circles overlap, i.e. they effectively intersect everywhere.
Arcs Closest Intersection
To calculate the intersection of two arcs, it is necessary to determine which of the two intersection points is relevant, see Figure 10.
We calculate the
centroid of the arc centre points,
then use the closest intersection point to the centroid, see Figure 10.
If the closest intersection point is within both arcs then the arcs intersect.
Contact us