nearestfunction
The bodies nearest to a body on a date, nearest first: by the angle between them in the sky of an observer, or by the distance between them in space. The Sun, the planets, the dwarf planets and the moons are searched; the target itself, and the body the sky is seen from, are not in the answer.
A sky angle is astrometric: the observer's place at the date, each body where it was when its light left (a second and a half for the Moon, hours for Neptune), with no aberration or light bending. It is the angle between two centres, found with an arc tangent so that it is as exact near 0 and 180 degrees as at 90. A distance is the straight line between the two centres at that instant, with no light time. Every result carries the accuracy to expect from the theories (the accuracy guide's limits, combined).
Import it
import { nearest } from "@johnmorrisdotca/wakusei-planets/nearest";
Definition
function nearest(target: BodyId, options: NearestOptions & { by: "space"; }): SpaceNeighbour[]
function nearest(target: BodyId, options?: NearestOptions & { by?: "sky"; }): SkyNeighbour[]
function nearest(target: BodyId, options: NearestOptions): SkyNeighbour[] | SpaceNeighbour[]
Parameters
| Name | Type | Description |
|---|---|---|
target | BodyId | The body to look around. |
options | NearestOptions |
|
Returns
SpaceNeighbour[] | SkyNeighbour[]
The bodies, nearest first, as { id, kind, angle, uncertaintyArcseconds } for the sky and { id, kind, distanceKm, distanceAu, uncertaintyKm } for space.
Examples
import { nearest } from "@johnmorrisdotca/wakusei-planets/nearest";
const date = Date.UTC(2020, 11, 21, 18);
console.log(nearest("jupiter", { count: 2, kind: "planet", date }).map((row) => `${row.id} ${row.angle.toFixed(2)}`).join(", "));
console.log(nearest("earth", { by: "space", kind: "planet", count: 2, date }).map((row) => `${row.id} ${row.distanceAu.toFixed(2)} au`).join(", "));saturn 0.10, mercury 29.25
mars 0.81 au, mercury 1.44 auWhat it prints (run when this page was built)