Skip to content

Documentation / @interstellar-tools/equations / bodyFixedToGeodetic

Function: bodyFixedToGeodetic() ​

ts
function bodyFixedToGeodetic(
  x: number,
  y: number,
  z: number,
  a: number,
  eSquared: number
): GeodeticCoordinatesInterface;

Defined in: cartography/body-fixed-to-geodetic.ts:82

Convert a body-fixed Cartesian position (ECEF for Earth) to geodetic coordinates: latitude, longitude and height.

There's no closed form for the latitude. This uses Bowring's iteration on the parametric latitude β:

tan⁡φ=z+e′2bsin3⁡βp−e2acos3⁡β,tan⁡β=batan⁡φ

and then

λ=atan2(y,x),h=pcos⁡φ+zsin⁡φ−a1−e2sin2⁡φ

Where:

  • p=x2+y2 is the distance from the rotation axis (m)
  • a is the equatorial radius, b=a1−e2 the polar radius (m)
  • e2 is the first eccentricity squared, e′2=e2/(1−e2) the second

Units

  • Inputs: x, y, z and a in m, eSquared dimensionless.
  • Output: phi and lambda in radians, h in m.

Notes

  • Starting from tan⁡β=az/(bp), two iterations reach sub-millimetre accuracy for points near Earth's surface; the loop runs until β stops changing, to at most 10 iterations.
  • The height formula is stable everywhere, the poles included. On the rotation axis, phi is ±π/2 and lambda is 0.
  • For a point on the surface, phi equals planetographicLatitudeOblate; this one also handles points above and below it.
  • geodeticToBodyFixed goes the other way.
In practiceApollo 11, in Earth orbit

32.672° N, 191.1 km up

At orbit insertion: 6 563.0 km from Earth's centre, at 32.502° N geocentric

Seen from Earth's centre, the insertion point was at 32.502°, the latitude that fixes the orbit's inclination. On a map it was 0.170° further north, the latitude the flight evaluation report gives.

ts
const lat = toRad(32.502);
const r = 6_563_041;
bodyFixedToGeodetic(
  r * Math.cos(lat),
  0,
  r * Math.sin(lat),
  6_378_137,
  0.00669437999014
);
// phi ≈ 32.672°, h ≈ 191.1 km

Parameters ​

ParameterTypeDescription
xnumberBody-fixed x in m (finite), through the prime meridian.
ynumberBody-fixed y in m (finite), through 90° east.
znumberBody-fixed z in m (finite), along the rotation axis.
anumberEquatorial radius a in m (finite, > 0).
eSquarednumberFirst eccentricity squared e2 (finite, in [0, 1)).

Returns ​

GeodeticCoordinatesInterface

The geodetic latitude, longitude and height.

Throws ​

  • If any input is not a finite number.
  • If a <= 0, eSquared is outside [0, 1), or the point is at the centre.

Example ​

ts
// 1 km above the North Pole on WGS84
const { phi, h } = bodyFixedToGeodetic(
  0,
  0,
  6_357_752.314,
  6_378_137,
  0.00669437999014
);
// phi = π/2, h ≈ 1 000 m

See ​