Crates.io | vsop87 |
lib.rs | vsop87 |
version | 3.0.0 |
source | src |
created_at | 2015-09-18 11:04:51.779524 |
updated_at | 2023-10-22 11:05:10.565472 |
description | Pure Rust VSOP87 algorithm implementation. Includes all VSOP87 algorith versions: VSOP87, VSOP87A, VSOP87B, VSOP87C, VSOP87D and VSOP87E. VSOP87 are a family of algorithms used to predict the position of planets in the solar system with great accuracy. That position can be used by astronomical software to create views of the sky, or by simulation software to know the position of the planets. |
homepage | |
repository | https://github.com/Razican/vsop87-rs |
max_upload_size | |
id | 3066 |
size | 19,453,711 |
This library implements the VSOP87 solutions to calculate the positions of the planets in the solar system. Full documentation can be found here.
The main module calculates heliocentric ecliptic orbital elements for the equinox J2000.0 for the planets in the solar system, the basic VSOP87 solution. There is one module per other VSOP87 implementation: VSOP87A, VSOP87B, VSOP87C, VSOP87D and VSOP87E. More information can be found here and here.
Each module has its own documentation, and here is the documentation on the base VSOP87 solution. The VSOP87 algorithm has great precision (under 1") for 4,000 years before and after J2000 epoch for Mercury, Venus, Earth-Moon barycenter and Mars, for 2,000 years in the case of Jupiter and Saturn and for 6,000 years for Uranus and Neptune.
The base VSOP87 solution calculates the orbital elements of the planets around
the Sun. The returned elements are a special VSOP87 orbital elements, that can be converted into
usual keplerian elements using the Into
trait. These elements are ideal to get an idea on how
the orbits are changing over time. It can also be used for other complex orbital computations.
As an example, here we calculate the orbital parameters for Mercury on the January 1st, 2000.
The VSOP87 algorithm requires dates to be entered as
Julian Day (JD). In our case, that date is
2451545.0
.
We first calculate the VSOP87 elements:
let vsop87_elts = vsop87::mercury(2451545.0);
assert!(vsop87_elts.a > 0.3870982121 && vsop87_elts.a < 0.3870982123);
assert!(vsop87_elts.l > 4.4026057778 && vsop87_elts.l < 4.4026057780);
assert!(vsop87_elts.k > 0.0446647517 && vsop87_elts.k < 0.0446647519);
assert!(vsop87_elts.h > 0.2007208957 && vsop87_elts.h < 0.2007208959);
assert!(vsop87_elts.q > 0.0406161540 && vsop87_elts.q < 0.0406161542);
assert!(vsop87_elts.p > 0.04563512 && vsop87_elts.p < 0.04563588);
Note that the >
and <
comparisons are there because floats should not be compared using
==
. Those numbers are retrieved from the original test data of the VSOP87 algorithm.
We can then convert them into keplerian elements, by using both KeplerianElements::from()
or
the into()
function in the VSOP87 elements. This also works the other way around:
use vsop87::{KeplerianElements, VSOP87Elements};
let elements = KeplerianElements::from(vsop87_elts);
let convert_back: VSOP87Elements = elements.into();
assert!(elements.semimajor_axis() > 0.387097 && elements.semimajor_axis() < 0.387099);
assert!(elements.eccentricity() > 0.205629 && elements.eccentricity() < 0.205631);
assert!(elements.inclination() > 0.122260 && elements.inclination() < 0.122261);
assert!(elements.ascending_node() > 0.843525 && elements.ascending_node() < 0.843527);
assert!(elements.periapsis() > 1.35183 && elements.periapsis() < 1.35185);
assert!(elements.mean_anomaly() > 4.40259 && elements.mean_anomaly() < 4.40261);
As you can see, these numbers perfectly match those from NASA.
This library is distributed under the terms of both the MIT license and the Apache License (Version 2.0), at your option. See LICENSE-APACHE, and LICENSE-MIT files for details.