Debian Codegraph @

src/lib.rs

raw symbols SCIP
1 #![warn(missing_docs)]
2 /*!
3 # pracstro - Compact Astronomy Library and Ephemeris Generator
4
5 pracstro is an astronomy library made from a collection of other algorithms that is
6 compact, principled, and easy to understand. It's made for calculating properties
7 of celestial objects, such as the moon, sun, planets, and stars.
8
9 ```
10 use pracstro::*;
11
12 let now_date = time::Date::from_calendar(2025, 4, 16, time::Angle::from_clock(0, 0, 0.0));
13 let now_time = time::Angle::from_clock(19, 41, 11.0);
14 let my_latitude = time::Angle::from_degrees(30.5);
15 let my_longitude = time::Angle::from_degrees(-110.0);
16
17 sol::VENUS.location(now_date).horizon(now_date, my_latitude, my_longitude); // Get the horizontal coordinates of Venus
18 moon::MOON.illumfrac(now_date); // The illuminated fraction of the moons surface
19 time::Angle::from_degrees(120.0).clock(); // 16h00m00s
20 ```
21
22 # Benchmarks
23
24 Although speed is not a direct goal of this library, the simplicity of the algorithms used often makes
25 the library much faster than other astronomy libraries. The tradeoff for this simplicity is
26 some accuracy, though the library remains accurate enough for most real-world use.
27
28 Average 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
37 This library contains 4 primary modules, which build upon the ones before them:
38 1. [`time`] for the conversion and representation of times, dates, and angles.
39 2. [`coord`] for the conversion and representation of coordinates.
40 3. [`sol`] for the calculation of properties of planets and the sun.
41 4. [`moon`] for the calculation of properties of the moon.
42
43 Each 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
50 These types have methods to get the properties of this data. Primarily in pairs of methods that convert to/from a certain
51 representation of that data. Although lone methods that get certain data for a type do exist.
52 */
53
54 pub mod time;
55
56 pub mod coord;
57
58 pub mod sol;
59
60 pub 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;