Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Great Circle Distance between two "P = (x, y, z)" points on a unit sphere

I need to calculate distance between two points, using their coordinates (x, y, z) on a unit sphere.

Both Haversine and Great Arc Distance use φ and λ (longitude and latitude). How do i write those Formulas for x, y, z?

like image 376
tory Avatar asked Oct 27 '25 09:10

tory


1 Answers

Generalizing to a sphere of radius R, so that the physical dimensions of expressions and variables is always apparent, we draw the following figure where you can see, on the plane that contains the three points, the points A and B on the surface of the sphere and the point O, the centre of the sphere, and also the arc of minimum length that connects A and B.

enter image description here

With reference to the figure and the text in it, you can compute the distance between points A and B like this:

  1. Compute the distance Δ = math.sqrt((x_B-x_A)**2+(y_B-y_A)**2+(z_B-z_A)**2)
  2. Compute the angle underlying one half of Δ, φ = math.asin((Δ/2/R))
  3. the distance on the great circle is gc_dist = 2*phi*R .

(you may want to use R = 1).

like image 195
gboffi Avatar answered Oct 28 '25 23:10

gboffi