distancefunction
The distance between two bodies on a date: the straight line between their centres at that instant, in kilometres and astronomical units, with no light time. Any two of the Sun, the planets, the dwarf planets and the moons.
Import it
import { distance } from "@johnmorrisdotca/wakusei-planets/nearest";
Definition
function distance(a: BodyId, b: BodyId, date?: When): Distance
Parameters
| Name | Type | Description |
|---|---|---|
a | BodyId | One body. |
b | BodyId | The other. |
date (optional) | When | undefined | The moment, a |
Returns
Distance
The distance and the accuracy to expect of it.
Examples
import { distance } from "@johnmorrisdotca/wakusei-planets/nearest";
const mars = distance("earth", "mars", Date.UTC(2003, 7, 27, 9));
console.log(mars.distanceAu.toFixed(4), Math.round(mars.distanceKm), "km");0.3727 55756681 kmWhat it prints (run when this page was built)