[Math] How to calculate distance between two points on the sphere

anglespherical coordinates

I have two azimuth and altitude angles for two points on a sphere. How can I calculate the spherical distance between those points? And how can I deduce this formula from first equations?

Best Answer

Write down the actual coordinate vectors of the points, using your two angles. Take the dot product of those two vectors. Assuming we're on the unit sphere, this will give you $\cos\alpha$, where $\alpha$ is the angle between the two vectors. Taking $\arccos$ of this number will give you $\alpha$, and hence the length of the great circle arc joining the original two points.