Distance through the Earth
This calculator calculates the distance from one point on the Earth to another point, going through the Earth, instead of going across the surface.
If you want to measure distance from one point on the Earth to another point, you should use the greatcircle or orthodromic distance formula. We even have two calculators for this: the one which uses haversine formula, and the another one which uses Vincenty formula.
However, what if you want to know the distance between two points on the Earth through the Earth, not across the surface? As it turns out, the problem is relatively simple, except for couple of gotchas. The calculator below finds the distance between two points through the Earth, and the derivation of formula with all gotchas can be found below the calculator.
Distance through the Earth
Ok, we have two points on the Earth surface, defined by their latitude and longitude, and we want to know the distance between them going "through" the Earth, instead of around it. Technically, we have spherical coordinates of each point in threedimensional space, because we know radius of the Earth, inclination angle (latitude) and azimuth angle (longitude). If we convert these to cartesian coordinates, with x, y, z in threedimensional space, we can easily find the distance using wellknown Euclidean distance formula:
So, let's define our Cartesian coordinate system. Origin will be the center of the Earth, xaxis will point to zero meridian intersection with the equator plane, yaxis will point to 90 degrees west meridian intersection with equator plane, and zaxis will point to the North.
is our longitude, is our latitude.
Cartesian coordinates can be obtained from spherical coordinates using the following relations:
We're almost done, but we still need to take into account couple of factors, which arise due to the fact that in the geodesy the Earth is approximated with oblate spheroid or ellipsoid of revolution. So, when we talk about coordinates, we talk about coordinates on the surface of reference ellipsoid used in the geodetic datum, in this case, WGS 84 (hence, the distance is also measured between two points of reference ellipsoid). The factors are:

Since the Earth is flattened at the poles and bulges at the equator, the Earth radius is not constant and depends on the latitude of the point. Thus we need to compute it for both points and this can be done with the help of this calculator.
 WGS 84 latitude of a point is geodetic latitude, which is determined by the angle between the equatorial plane and normal to the ellipsoid, as opposed to geocentric latitude, which is determined by the angle between the equatorial plane and line joining the point to the centre of the ellipsoid. Since the origin of our cartesian system is the center of the Earth, we need to convert geodetic latitude to geocentric latitude for both points.
We account for those using these formulas:
,
where is geocentric latitude, is geodetic latitude,  semimajor axis of the ellipsoid,  semiminor axis of the ellipsoid.
To summarize, to calculate the distance we should do the following:
 Calculate Earth radius at each point
 Calculate geocentric latitude at each point
 Convert spherical coordinates of each point to cartesian coordinates, that is, from calculated radius, geocentric latitude and longitude to x,y,z.
 Calculate distance using Euclidean distance formula
Comentarios