Is there a function or set of functions that I can use to graph the great circle of any two points on an equirectangular map? I can translate the x,y coordinates from the map to latitude and longitude and understand that the great circle distance is the length of the arc of the center angle at the radius, but I am having problems figuring out how I can graph the circle onto the rest of the map.


Can you transfer from lat/lon to xy as well? Let's assume you can.

Broad strokes:

Step 1: Start with two distinct points, $P$ and $Q$, that are not antipodal.

Step 2: Convert to lat/lon.

Step 3: Convert to vector form (i.e., a triple $x, y, z$ in 3-space)

Step 4: Find a basis $b_1, b_2$ for the plane they span.

Step 5: For $a = 0$ to $360$ degrees, generate $\cos(a) b_1 + \sin(a) b_2$ as a vector.

Step 6: Convert each of these vector triples to a lat-lon pair, and then to xy.

Step 7: Connect the dot of the resulting xy points.

Details: Step 3: If the latitude is $s$ and longitude is $t$, the vector form of your point is $$ \begin{bmatrix} \sin(s) \cos t\\ \cos(s) \\ \sin(s) \sin t \end{bmatrix} $$.

Step 4: Given two vector-form points $u$ and $v$, let $b_1 = u$ and then do the following: Compute $r = u_x v_x + u_y v_y + u_z v_z$, where $u_x, u_y,$ and $u_z$ denote the first, second, and third entries of $u$, respectively, and similarly for $v$. Let

$$ h = \begin{bmatrix} u_x - r v_x\\ u_y - r v_y\\ u_z - r v_z \end{bmatrix} $$.

Then let $c = \sqrt{h_x^2 + h_y^2 + h_z^2}$, and let

$$ b_2 = \begin{bmatrix} h_x/s\\ h_y/s\\ h_z/s \end{bmatrix} $$.

Step 5: By "generate as a vector, " I mean, compute the vector $$ k = \begin{bmatrix} \cos(a) b_{1,x} + \sin(a) b_{2,x}\\ \cos(a) b_{1,y} + \sin(a) b_{2,y}\\ \cos(a) b_{1,z} + \sin(a) b_{2,z} \end{bmatrix}. $$

Step 6: To convert $k$ back to lat/long form, do the following: $$ lat = \arccos(k_y)\\ long = \text{atan2}(k_x, k_z) $$


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.