Skip to content

Documentation / @interstellar-tools/equations / centralAngleFromVectors

Function: centralAngleFromVectors() ​

ts
function centralAngleFromVectors(
  r1: Vector3DTupleType,
  r2: Vector3DTupleType
): Radians;

Defined in: cartography/central-angle-from-vectors.ts:43

Compute the central angle between two position vectors, without trigonometry on latitude and longitude.

Δσ=atan2(‖r1×r2‖, r1⋅r2)

Where:

  • r1, r2 are the two positions, from the body's centre

Units

  • Inputs: r1, r2 in any length unit, the same for both.
  • Output: Δσ in radians, in [0, π].

Notes

  • The atan2 form is accurate at every angle, unlike arccos of the normalised dot product, which loses precision near 0 and π.
  • The vectors' lengths don't matter, only their directions: the angle between a ground station and a satellite above another point is the angle between the points below them.
  • Works with body-fixed positions from geodeticToBodyFixed, giving the angle at the centre, not along the ellipsoid.

Parameters ​

ParameterTypeDescription
r1Vector3DTupleTypeFirst position vector (finite components, not zero).
r2Vector3DTupleTypeSecond position vector (finite components, not zero).

Returns ​

Radians

The central angle Δσ in radians.

Throws ​

  • If a component is not a finite number.
  • If either vector is zero.

Example ​

ts
// The x and y axes are a quarter turn apart
centralAngleFromVectors([1, 0, 0], [0, 5, 0]); // π/2

See ​