Planets, Sun and Moon
You want to know where Mars or the Moon is at a given time, and you’d rather
not download and ship a JPL kernel to find out. celestial-ephemeris builds
two published theories into the crate as truncated series. VSOP2013 (Simon et
al. 2013) covers the planets, and ELP/MPP02 (Chapront & Francou 2003) covers
the Moon. They need no data files at run time.
Here are Mars and Jupiter as seen from the Earth’s center:
use celestial_ephemeris::earth::Vsop2013Earth;
use celestial_ephemeris::planets::{Vsop2013Jupiter, Vsop2013Mars};
use celestial_time::scales::tdb::tdb_from_calendar;
fn main() -> Result<(), Box<dyn std::error::Error>> {
let tdb = tdb_from_calendar(2026, 10, 5, 0, 0, 0.0)?;
let earth = Vsop2013Earth::new().heliocentric_state(&tdb)?;
let (mars, mars_velocity) = Vsop2013Mars.geocentric_state(&tdb, &earth)?;
let jupiter = Vsop2013Jupiter.geocentric_position(&tdb, &earth.0)?;
println!("Mars: {:.6} AU, {:.6} AU/day", mars.magnitude(), mars_velocity.magnitude());
println!("Jupiter: {:.6} AU", jupiter.magnitude());
Ok(())
}
The geocentric methods take the Earth’s heliocentric position or state as an argument instead of computing it, so one Earth evaluation per epoch serves every planet.
The truncated series are good to about 30 mas for Mercury through Saturn between 1950 and 2050. Accuracy has the per-body numbers. For anything tighter, or for barycentric positions, use a JPL SPK kernel.
Conventions
Every body on this page uses the same conventions:
- Input: a
&TDBepoch. - Output: ICRS axes, positions in AU and velocities in AU/day.
- Errors: every method returns
AstroResult.
The series measure time as (jd1 − 2451545.0) + jd2 days from J2000. The two
parts of the Julian date are never added first, so a time of day held in
jd2 keeps its precision. tdb_from_calendar already splits the date this
way, with midnight in jd1 and the time of day in jd2.
Positions are geometric: where the body is at that instant. They include no light time, aberration or light deflection. Light time shows how to add the first of these.
“Heliocentric” means relative to the Sun’s center, which differs from the solar system barycenter. Between 1950 and 2050 the Sun moves about the barycenter at 8.5 to 16.1 m/s. Aberration computed from heliocentric velocities is therefore off by up to 11 mas. When that matters, take the Earth’s barycentric velocity from a JPL kernel.
Planets
Each planet is a unit struct in celestial_ephemeris::planets:
| Type | Body |
|---|---|
Vsop2013Mercury | Mercury |
Vsop2013Venus | Venus |
Vsop2013Emb | Earth-Moon barycenter |
Vsop2013Mars | Mars |
Vsop2013Jupiter | Jupiter |
Vsop2013Saturn | Saturn |
Vsop2013Uranus | Uranus |
Vsop2013Neptune | Neptune |
Vsop2013Pluto | Pluto |
All of them have the same four methods:
| Method | Returns |
|---|---|
heliocentric_position(&tdb) | Vector3 position |
heliocentric_state(&tdb) | (Vector3, Vector3) position, velocity |
geocentric_position(&tdb, &earth) | heliocentric position minus earth |
geocentric_state(&tdb, &earth_state) | heliocentric state minus earth_state |
Vector3 is celestial_core::matrix::Vector3.
Earth and Sun
VSOP2013 has no series for the Earth itself. Vsop2013Earth computes it from
the Earth-Moon barycenter by removing the Moon’s share:
earth = emb − moon × MOON_EMB_MASS_RATIO
Here moon comes from ElpMpp02Moon::new(). The ratio is the Moon’s fraction
of the Earth-Moon mass, from celestial_core::constants. Since the Earth
depends on the Moon, Vsop2013Earth accepts only dates in the Moon’s range
(see Date ranges).
Vsop2013Earth has only heliocentric_position and heliocentric_state.
Vsop2013Sun has all four planet methods, so code that loops over bodies can
treat the Sun like any other. Its heliocentric position and velocity are zero,
and its geocentric values are the negated Earth.
Moon
ElpMpp02Moon returns the geocentric Moon directly, with no Earth argument:
use celestial_ephemeris::moon::ElpMpp02Moon;
use celestial_time::scales::tdb::tdb_from_calendar;
fn main() -> Result<(), Box<dyn std::error::Error>> {
let tdb = tdb_from_calendar(2026, 10, 5, 0, 0, 0.0)?;
let moon = ElpMpp02Moon::new();
let position = moon.geocentric_position(&tdb)?;
let (_, velocity) = moon.geocentric_state(&tdb)?;
println!("Moon: {:.8} AU, {:.8} AU/day", position.magnitude(), velocity.magnitude());
Ok(())
}
The theory’s authors fitted its constants two ways. Each fit has its own constructor:
| Constructor | Constants fitted to | Rotation to ICRS |
|---|---|---|
new() | lunar laser ranging | ε = 84381.406″ (IAU 2006 obliquity) |
with_de405_fit() | JPL’s DE405 | ε = 84381.4096″, φ = −0.05028″ (fitted with DE405) |
ElpMpp02Moon::default() is the same as new(), and Vsop2013Earth uses
new() too. Against DE432s over 1950 to 2050, the shipped series misses by up
to 67 m with new() and 36 m with with_de405_fit().
Accuracy breaks these numbers down.
Given the same truncated series, the crate reproduces the authors’ Fortran bit for bit, when that Fortran is compiled without FMA.
Date ranges
Each theory rejects epochs outside its published range:
| Theory | Bodies | Years | TDB Julian dates |
|---|---|---|---|
| VSOP2013 | Mercury to Neptune, Earth-Moon barycenter, Sun | −4000 to +8000 | 260045.0 to 4643045.0 |
| VSOP2013 | Pluto | 0 to +4000 | 1721045.0 to 3182045.0 |
| ELP/MPP02 | Moon, Earth | −3000 to +3000 | 625295.0 to 2816795.0 |
Both ends are included. An epoch outside the range returns
AstroError::MathError with kind OutOfRange, and the message names the
theory and its years. A NaN or infinite epoch returns kind NotFinite:
use celestial_core::errors::{AstroError, MathErrorKind};
use celestial_ephemeris::planets::Vsop2013Pluto;
use celestial_time::julian::JulianDate;
use celestial_time::scales::tdb::TDB;
fn main() {
let year_5000 = TDB::from_julian_date(JulianDate::new(3547295.0, 0.0));
match Vsop2013Pluto.heliocentric_position(&year_5000) {
Err(AstroError::MathError { kind: MathErrorKind::OutOfRange, message, .. }) => {
println!("{message}");
}
other => println!("unexpected: {other:?}"),
}
}
These ranges are the theories’ own. The shipped tables were measured only over 1950 to 2050, so expect larger errors far from that span. See Outside 1950–2050.
Light time
The output is geometric, so correcting for light time is up to you. To see a
planet from the Earth at time t, evaluate the planet at t − τ, where τ
is the light-travel time. A fixed-point loop converges in a few passes:
use celestial_core::constants::SPEED_OF_LIGHT_AU_PER_DAY;
use celestial_ephemeris::earth::Vsop2013Earth;
use celestial_ephemeris::planets::Vsop2013Mars;
use celestial_time::scales::tdb::tdb_from_calendar;
fn main() -> Result<(), Box<dyn std::error::Error>> {
let tdb = tdb_from_calendar(2026, 10, 5, 0, 0, 0.0)?;
let earth = Vsop2013Earth::new().heliocentric_position(&tdb)?;
let mut mars = Vsop2013Mars.geocentric_position(&tdb, &earth)?;
for _ in 0..3 {
let tau = mars.magnitude() / SPEED_OF_LIGHT_AU_PER_DAY;
let emitted = tdb.add_days(-tau);
mars = Vsop2013Mars.heliocentric_position(&emitted)? - earth;
}
println!("Mars, corrected for light time: {:.6} AU", mars.magnitude());
Ok(())
}
Both positions in this loop are heliocentric, so it ignores how far the Sun
moves during τ. That error is at most the Sun’s speed divided by the speed
of light, 11 mas.
Where next
- Accuracy: how far each body is from DE432s, and why.
- JPL SPK Kernels: barycentric positions and kernel accuracy.
- Regenerating the Tables: keep more or fewer terms.