pracstro/lib.rs
1#![warn(missing_docs)]
2/*!
3# pracstro - Compact Astronomy Library and Ephemeris Generator
4
5pracstro is an astronomy library made from a collection of other algorithms that is
6compact, principled, and easy to understand. It's made for calculating properties
7of celestial objects, such as the moon, sun, planets, and stars.
8
9```
10use pracstro::*;
11
12let now_date = time::Date::from_calendar(2025, 4, 16, time::Angle::from_clock(0, 0, 0.0));
13let now_time = time::Angle::from_clock(19, 41, 11.0);
14let my_latitude = time::Angle::from_degrees(30.5);
15let my_longitude = time::Angle::from_degrees(-110.0);
16
17sol::VENUS.location(now_date).horizon(now_date, my_latitude, my_longitude); // Get the horizontal coordinates of Venus
18moon::MOON.illumfrac(now_date); // The illuminated fraction of the moons surface
19time::Angle::from_degrees(120.0).clock(); // 16h00m00s
20```
21
22# Benchmarks
23
24Although speed is not a direct goal of this library, the simplicity of the algorithms used often makes
25the library much faster than other astronomy libraries. The tradeoff for this simplicity is
26some accuracy, though the library remains accurate enough for most real-world use.
27
28Average of many tests, n = 40,000:
29
30| Test | `pracstro` | [`astro`](https://crates.io/crates/astro) |
31|----------------|----------------------|---------------------|
32| Moon Phase | 558ns | 2,979ns (3µs) |
33| Jupiter Coords | 601ns | 70,860ns (70µs) |
34| Full ephemeris | 3,406ns (3.4µs) | 1,208,833ns (1.2ms) |
35
36# Structure
37This library contains 4 primary modules, which build upon the ones before them:
381. [`time`] for the conversion and representation of times, dates, and angles.
392. [`coord`] for the conversion and representation of coordinates.
403. [`sol`] for the calculation of properties of planets and the sun.
414. [`moon`] for the calculation of properties of the moon.
42
43Each of these have one or two types that represent a certain kind of data:
44- [`Date`](time::Date) - An instant in continuous time.
45- [`Angle`](time::Angle) - An angle automatically corrected to be between \[0°, 360°\]. Which can also represent a time of day.
46- [`Coord`](coord::Coord) - A pair of angles, representing latitude/longitude on a sphere.
47- [`Planet`](sol::Planet) - A planets orbital properties, along with data required for orbital correction.
48- [`Moon`](moon::Moon) - The moons orbital properties.
49
50These types have methods to get the properties of this data. Primarily in pairs of methods that convert to/from a certain
51representation of that data. Although lone methods that get certain data for a type do exist.
52*/
53
54pub mod time;
55
56pub mod coord;
57
58pub mod sol;
59
60pub mod moon;
61
62// Since the Probe Module is experimental and will be in development until a method of getting comet positions is worked out, it is not shipped with the main library
63//pub mod probe;
64//pub mod celobj;