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.
Where:
, are the two positions, from the body's centre
Units
- Inputs:
r1,r2in any length unit, the same for both. - Output:
in radians, in [0, π].
Notes
- The
atan2form is accurate at every angle, unlikeof 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
| Parameter | Type | Description |
|---|---|---|
r1 | Vector3DTupleType | First position vector (finite components, not zero). |
r2 | Vector3DTupleType | Second position vector (finite components, not zero). |
Returns
The central angle
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