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?
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.

With reference to the figure and the text in it, you can compute the distance between points A and B like this:
Δ = math.sqrt((x_B-x_A)**2+(y_B-y_A)**2+(z_B-z_A)**2)φ = math.asin((Δ/2/R))gc_dist = 2*phi*R .(you may want to use R = 1).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With