Reference · Pure coordinate conversions
cartesianToSphericalfunction
Convert Cartesian to spherical. Zero vectors throw; longitude at either pole is conventionally zero.
Import it
import { cartesianToSpherical } from "@johnmorrisdotca/wakusei-planets/coordinates";
Definition
function cartesianToSpherical(value: CartesianAu): SphericalAu
Parameters
| Name | Type | Description |
|---|---|---|
value | CartesianAu | Coordinates with explicit origin, frame, epoch and geometric corrections. |
Returns
SphericalAu
Spherical angles in degrees and radius in AU with the same context.
Examples
import { cartesianToSpherical } from "@johnmorrisdotca/wakusei-planets/coordinates";
console.log(cartesianToSpherical({ origin: "heliocentric", frame: "eclipticJ2000", epoch: "J2000", corrections: "geometric", xAu: 0, yAu: 1, zAu: 0 }));{
origin: 'heliocentric',
frame: 'eclipticJ2000',
epoch: 'J2000',
corrections: 'geometric',
longitude: 90,
latitude: 0,
distanceAu: 1
}What it prints (run when this page was built)