Skip to content

Documentation / @interstellar-tools/equations / geodeticToBodyFixed

Function: geodeticToBodyFixed() ​

ts
function geodeticToBodyFixed(
  phi: Radians,
  lambda: Radians,
  h: number,
  a: number,
  eSquared: number
): Vector3DTupleType;

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

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

x=(N+h)cos⁡φcos⁡λy=(N+h)cos⁡φsin⁡λz=(N(1−e2)+h)sin⁡φN=a1−e2sin2⁡φ

Where:

  • φ is the geodetic latitude and λ the longitude (rad)
  • h is the height above the ellipsoid, along its normal (m)
  • a is the equatorial radius (m) and e2 the first eccentricity squared
  • N is the prime vertical radius of curvature (m), from primeVerticalRadiusOfCurvature

Units

  • Inputs: phi and lambda in radians, h and a in m, eSquared dimensionless.
  • Output: [x, y, z] in m, with z along the rotation axis and x through the prime meridian.

Notes

  • Geodetic latitude is the angle of the ellipsoid's normal, the latitude on maps. The geocentric latitude, the angle seen from the centre, is atan2(z, hypot(x, y)) of the result, and is smaller everywhere but the equator and the poles.
  • WGS84: a=6378137 m, e2=0.00669437999014. Get e2 from the radii with eccentricitySquaredOblateSpheroid.
  • bodyFixedToGeodetic goes the other way.
In practiceApollo 11, on Pad 39A

6 373.3 km

From Earth's centre, at 28.608° N geodetic, 80.604° W on the WGS84 ellipsoid

The geocentric latitude is 28.447°, 0.161° less than on the map. That's the latitude the launch-site formulas such as surfaceRotationSpeed need.

ts
const [x, y, z] = geodeticToBodyFixed(
  toRad(28.608422),
  toRad(-80.604133),
  0,
  6_378_137,
  0.00669437999014
);
Math.hypot(x, y, z); // ≈ 6 373 266 m
toDeg(Math.atan2(z, Math.hypot(x, y))); // ≈ 28.447°

Parameters ​

ParameterTypeDescription
phiRadiansGeodetic latitude φ in radians (finite, in [-π/2, π/2]).
lambdaRadiansLongitude λ in radians, east positive (finite).
hnumberHeight h above the ellipsoid in m (finite; negative below it).
anumberEquatorial radius a in m (finite, > 0).
eSquarednumberFirst eccentricity squared e2 (finite, in [0, 1)).

Returns ​

Vector3DTupleType

Body-fixed position [x, y, z] in m.

Throws ​

  • If any input is not a finite number.
  • If phi is outside [-π/2, π/2], a <= 0, or eSquared is outside [0, 1).

Example ​

ts
import type { Radians } from '@interstellar-tools/types';

// On the equator at the prime meridian, 100 m up
geodeticToBodyFixed(
  0 as Radians,
  0 as Radians,
  100,
  6_378_137,
  0.00669437999014
);
// [6 378 237, 0, 0]

See ​