Function Repository Resource:

LoxodromeDistance

Source Notebook

Compute the loxodrome distance between two points on a unit sphere

Contributed by: Jan Mangaldan

ResourceFunction["LoxodromeDistance"][p1,p2]

gives the loxodrome distance between points p1 and p2 lying on a sphere centered at the origin.

Details

The loxodrome, or rhumb line, is a curve of constant bearing/direction on the sphere.
ResourceFunction["LoxodromeDistance"] gives the arclength of the loxodrome connecting p1 and p2.

Examples

Basic Examples (1) 

The loxodrome distance of two points on a sphere of radius 2:

In[1]:=
ResourceFunction["LoxodromeDistance"][
  FromSphericalCoordinates[{2, 5 \[Pi]/6, \[Pi]/4}], FromSphericalCoordinates[{2, \[Pi]/4, 2 \[Pi]/3}]] // N
Out[1]=

Scope (1) 

Loxodrome distance for two randomly chosen points on the unit sphere:

In[2]:=
{p1, p2} = RandomPoint[Sphere[], 2];
ResourceFunction["LoxodromeDistance"][p1, p2]
Out[3]=

Properties and Relations (5) 

Two points on the unit sphere:

In[4]:=
{p1, p2} = Normalize /@ RandomVariate[NormalDistribution[], {2, 3}]
Out[4]=

Compute the corresponding longitudes and latitudes:

In[5]:=
{{\[Lambda]1, \[Phi]1}, {\[Lambda]2, \[Phi]2}} = MapAt[\[Pi]/2 - # &, Composition[Reverse, Rest, ToSphericalCoordinates] /@ {p1, p2}, {All, 2}]
Out[5]=

Define and visualize the loxodrome joining the two points:

In[6]:=
loxo[\[Lambda]_] = With[{\[Phi] = Gudermannian[(
        InverseGudermannian[\[Phi]2] - InverseGudermannian[\[Phi]1])/(\[Lambda]2 - \[Lambda]1) (\[Lambda] - \[Lambda]1) + InverseGudermannian[\[Phi]1]]}, {Cos[\[Phi]] Cos[\[Lambda]], Cos[\[Phi]] Sin[\[Lambda]], Sin[\[Phi]]}];
Show[ParametricPlot3D[
  loxo[\[Lambda]], {\[Lambda], \[Lambda]1, \[Lambda]2}], Graphics3D[{Opacity[1/2], Sphere[]}], PlotRange -> All]
Out[7]=

Find the arclength of the loxodrome:

In[8]:=
ArcLength[loxo[\[Lambda]], {\[Lambda], \[Lambda]1, \[Lambda]2}]
Out[8]=

This is equivalent to the result of LoxodromeDistance:

In[9]:=
ResourceFunction["LoxodromeDistance"][p1, p2]
Out[9]=

Version History

  • 1.0.0 – 19 September 2022

Source Metadata

License Information