Skip to content

Documentation / @interstellar-tools/maps / orthographic

Function: orthographic() ​

ts
function orthographic(
  phi: Radians,
  lambda: Radians,
  R: number,
  options?: AzimuthalOptionsInterface
): ProjectedPointInterface;

Defined in: projections/orthographic.ts:58

Project a point on a sphere with the orthographic projection: the globe as it looks from infinitely far away, above the map's centre.

x=Rcos⁡φsin⁡(λ−λ0),y=R(cos⁡φ0sin⁡φ−sin⁡φ0cos⁡φcos⁡(λ−λ0))

Where:

  • φ and λ are the point's latitude and longitude (rad)
  • φ0 and λ0 are the map's centre (rad)
  • R is the sphere's radius (m)

Units

  • Inputs: angles in radians, R in m.
  • Output: { x, y } in m.

Notes

  • The near hemisphere fills a disc of radius R: a point at angular distance c from the centre is Rsin⁡c from it, in its true direction. It keeps neither areas nor angles; shapes are squashed towards the edge, as on a photograph of a planet.
  • Only the near hemisphere can be shown. A point on the far side, with cos⁡c=sin⁡φ0sin⁡φ+cos⁡φ0cos⁡φcos⁡(λ−λ0)<0, throws a RangeError; to draw a globe, skip the points where cos⁡c is negative. Points on the horizon, cos⁡c=0, are shown, allowing for rounding.

Parameters ​

ParameterTypeDescription
phiRadiansLatitude φ in radians (finite, in [−π/2, π/2]).
lambdaRadiansLongitude λ in radians (finite).
RnumberRadius R of the sphere in m (finite, > 0).
options?AzimuthalOptionsInterfacephi0 and lambda0, the map's centre (radians, both default to 0).

Returns ​

ProjectedPointInterface

The point on the map, { x, y } in m.

Throws ​

  • If any input is not a finite number.
  • If phi or phi0 is outside [−π/2, π/2], R <= 0, or the point is on the far side.

Example ​

ts
// Mars seen from far above 0° N, 0° E: a point at 30° N, 60° E
orthographic(toRad(30), toRad(60), 3_389_500);
// ≈ { x: 2 542 125, y: 1 694 750 } m

See ​