I choose two Points in Berlin with the coordinates:
1: lat: 52.511206 long: 13.546486
2: lat: 52.527501 long: 13.319206
With an online tool I got the distance between the two points with around: 15.48 kilometers, what seems to be correct.
Now I tried to calculate the distance by my own. In my script it says that its possible to transform polar coordinates to cartesian coordinates with the origin of the earths middle point:
x: sin(lat) * cos(long)
y: sin(lat) * sin(long)
z: cos(long)
Because the earth is round and not a plane, to calculate the distance with formula is not 100% exact but for this little distance it should work.
So I inserted my numbers and got this results:
1: 0.566225110618 0.52677679361 0.72975322153
2: 0.43345006608 0.64846301808 0.55692671558
With the euclidian distance I got: 0.24752019375
So the numbers for me seem not be coorect
How do I have to use the forumla? Do I have to multiply the result with something? Thanks
Earth is not in a sphere form, instead it looks like an ellipsoid, squeezed between North and South Poles.
The latitude-longitude pairs are calculated considering the flattening coefficient ($f$) and eccentricity ($e_1$, $e_2$).
Here the detailed calculation method is:
http://www.colorado.edu/geography/gcraft/notes/datum/gif/xyzllh.gif