Documentation / @interstellar-tools/equations / sunPosition
Function: sunPosition()
ts
function sunPosition(date: Date): SunPositionInterface;Defined in: cartography/sun-position.ts:74
Compute the Sun's position seen from Earth's centre at a moment: right ascension, declination and distance, with the low-precision formulas of the Astronomical Almanac.
and then
Where:
is the number of days since J2000.0, 2000-01-01T12:00:00 (d) is the Sun's mean longitude, corrected for aberration is the Sun's mean anomaly is the Sun's ecliptic longitude; its ecliptic latitude is 0 is the obliquity of the ecliptic is the distance from Earth to the Sun
Units
- Input: a
Date. - Output:
rightAscensionanddeclinationin radians,distancein m, andrin m: see SunPositionInterface.
Notes
- Good to about 0.01° between 1950 and 2050, and slowly worse outside it: enough to light a hillside or to tell whether a satellite is in Earth's shadow, not enough to point a solar telescope.
- The position is geocentric. From Earth's surface the Sun appears up to 8.8″ lower, its parallax, which is well below the formula's accuracy.
- The axes are the mean equator and equinox of the date, close enough to SGP4's TEME frame to compare with a satellite's position.
Parameters
| Parameter | Type | Description |
|---|---|---|
date | Date | The moment, as a Date. |
Returns
The right ascension, declination, distance and position: see SunPositionInterface.
Throws
If date is not a valid Date.
Example
ts
// The June solstice of 2026: the Sun at its farthest north
const { declination, distance } = sunPosition(new Date('2026-06-21T08:24:00Z'));
declination; // ≈ 0.4091 rad, 23.44°
distance; // ≈ 1.5203e11 m, 1.0163 auSee
- greenwichMeanSiderealTime
- https://aa.usno.navy.mil/faq/sun_approx The Astronomical Almanac's approximate solar coordinates