Skip to content

Documentation / @interstellar-tools/equations / horizonSurfaceDistance

Function: horizonSurfaceDistance() ​

ts
function horizonSurfaceDistance(h: number, R: number): number;

Defined in: cartography/horizon-surface-distance.ts:42

Compute the distance along the surface to the horizon for an observer at a height above a sphere.

s=Rarccos⁡RR+h=Ratan2(2Rh+h2, R)

Where:

  • R is the sphere's radius (m)
  • h is the observer's height above the surface (m)

Units

  • Inputs: h and R in m.
  • Output: s in m, along the surface from the point below the observer to the horizon.

Notes

  • Computed with atan2, which stays accurate for small heights where arccos of a number close to 1 loses most of its digits.
  • Slightly shorter than the line of sight horizonDistance; the two agree for h≪R and part ways from orbit.
  • s/R is the central angle from the observer to the horizon: the radius of what a satellite can see, as an angle.

Parameters ​

ParameterTypeDescription
hnumberHeight h above the surface in m (finite, >= 0).
RnumberRadius R of the sphere in m (finite, > 0).

Returns ​

number

The distance along the surface to the horizon s in m.

Throws ​

  • If any input is not a finite number.
  • If h < 0 or R <= 0.

Example ​

ts
// The ISS, 420 km above a 6 371 km Earth
horizonSurfaceDistance(420_000, 6_371_000); // ≈ 2 252 km, against 2 351 km in a straight line

See ​