astronomical_quantities/
lib.rs

1// ---------------------------------------------------------------------------
2// Copyright:   (c) 2021 ff. Michael Amrhein (michael@adrhinum.de)
3// License:     This program is part of a larger application. For license
4//              details please read the file LICENSE.TXT provided together
5//              with the application.
6// ---------------------------------------------------------------------------
7// $Source:     astronimical_quantities/src/lib.rs $
8// $Revision:   2022-07-05T18:33:39+02:00 $
9
10#![doc = include_str ! ("../README.md")]
11#![cfg_attr(not(feature = "std"), no_std)]
12#![allow(dead_code)]
13
14use quantities::prelude::*;
15
16#[quantity]
17#[ref_unit(Solar_Mass, "M☉", "Reference unit of quantity `Mass`")]
18#[unit(Lunar_Mass, "M☾", 3.694329684197616e-8, "1/27068510·M☉")]
19#[unit(Earth_Mass, "M🜨", 3.003489616124103e-6, "10000/3329460487·M☉")]
20#[unit(Jupiter_Mass, "M♃", 9.547918983127074e-4, "1000000/1047348644·M☉")]
21/// The quantity of matter in an astonomical body.
22///
23/// Reference unit: Solar Mass ('M☉')
24///
25/// Predefined units:
26///
27/// | Symbol | Name            | Definition            | Equivalent in 'M☉'   |
28/// |--------|-----------------|-----------------------|----------------------|
29/// | M☾     | Lunar Mass      | 1/27068510 M☉         | 3.694329684197616e-8 |
30/// | M🜨     | Earth Mass      | 10000/3329460487 M☉   | 3.003489616124103e-6 |
31/// | M♃     | Jupiter Mass    | 1000000/1047348644 M☉ | 9.547918983127074e-4 |
32pub struct Mass {}
33
34#[quantity]
35#[ref_unit(
36    Astronomical_Unit,
37    "au",
38    "Reference unit of quantity `Length` (= 149597870700·m)"
39)]
40#[unit(Kilometer, "km", 6.6845871222684464e-9, "1000·m")]
41#[unit(Lightsecond, "ls", 0.002003988804100004, "299792458·m")]
42#[unit(Lightyear, "ly", 63241.07708426629, "31557600·ls")]
43#[unit(Parsec, "pc", 206264.80624709636, "648000/π·au")]
44#[unit(Kilolightyear, "kly", 63241077.08426629, "1000·ly")]
45#[unit(Kiloparsec, "kpc", 206264806.24709636, "1000·pc")]
46#[unit(Megalightyear, "Mly", 63241077084.26629, "10⁶·ly")]
47#[unit(Megaparsec, "Mpc", 206264806247.09636, "10⁶·pc")]
48#[unit(Gigalightyear, "Gly", 63241077084266.29, "10⁹·ly")]
49#[unit(Gigaparsec, "Gpc", 206264806247096.36, "10⁹·pc")]
50/// The quantity of distance between two points in spacetime.
51///
52/// Reference unit: Astronomical Unit ('au')
53///
54/// Predefined units:
55///
56/// | Symbol | Name                    | Definition     | Equivalent in 'au'   |
57/// |--------|-------------------------|----------------|----------------------|
58/// | km     | Kilometer               | 1000·m         | 6.684587122268446e-9 |
59/// | ls     | Lightsecond             | 299792458·m    | 0.002003988804100004 |
60/// | ly     | Lightyear               | 31557600·ls    | 63241.07708426629    |
61/// | pc     | Parsec                  | 648000/π·au    | 206264.80624709636   |
62/// | kly    | Kilolightyear           | 1000·ly        | 63241077.08426629    |
63/// | kpc    | Kiloparsec              | 1000·pc        | 206264806.24709636   |
64/// | Mly    | Megalightyear           | 10⁶·ly         | 63241077084.26629    |
65/// | Mpc    | Megaparsec              | 10⁶·pc         | 206264806247.09636   |
66/// | Gly    | Gigalightyear           | 10⁹·ly         | 63241077084266.29    |
67/// | Gpc    | Gigaparsec              | 10⁹·pc         | 206264806247096.36   |
68pub struct Length {}
69
70#[quantity]
71#[ref_unit(Day, "d", "Reference unit of quantity `Duration` (= 24·h)")]
72#[unit(Second, "s", 1.1574074074074073e-5, "SI reference unit")]
73#[unit(Minute, "min", 0.0006944444444444445, "60·s")]
74#[unit(Hour, "h", 0.041666666666666664, "60·min")]
75#[unit(Sideral_Day, "dₛ", 0.9972685185185185, "a·d/(a + d)")]
76#[unit(Julian_Year, "a", 365.25, "365.25·d")]
77#[unit(Gregorian_Year, "yr", 365.2425, "365.2425·d")]
78#[unit(
79    Earth_Period,
80    "T🜨",
81    365.256363004,
82    "Earth's Orbital Period (≈ 365.256363004·d)"
83)]
84/// Duration: 'what a clock reads'
85///
86/// Reference unit: Day ('d')
87///
88/// Predefined units:
89///
90/// | Symbol | Name                | Definition        | Equivalent in 'd'     |
91/// |--------|---------------------|-------------------|-----------------------|
92/// | s      | Second              | SI reference unit | 1.1574074074074073e-5 |
93/// | min    | Minute              | 60·s              | 0.0006944444444444445 |
94/// | h      | Hour                | 60·min            | 0.041666666666666664  |
95/// | dₛ     | Siderial Day        | a·d/(a + d)       | 0.9972685185185185    |
96/// | a      | Julian Year         | 365.25·d          | 365.25                |
97/// | yr     | Gregorian Year      | 365.2425·d        | 365.2425              |
98/// | T🜨     | Earth's Orbital Period | ≈ 365.256363004·d | 365.256363004      |
99pub struct Duration {}
100
101#[quantity(Length / Duration)]
102#[ref_unit(
103    Astronomical_Units_per_Day,
104    "au/d",
105    "Reference unit of quantity `Speed`"
106)]
107#[unit(Kilometer_per_Hour, "km/h", 1.604300909344427e-7, "km/h")]
108#[unit(Meter_per_Second, "m/s", 5.775483273639937e-7, "SI reference unit")]
109#[unit(Speed_of_Light, "c", 173.14463267424034, "ls/s")]
110/// Magnitude of the change of an objects position per unit of time
111///
112/// Definition: Length/Duration
113///
114/// Reference unit: Astronomical Units per Day ('au/d')
115///
116/// Predefined units:
117///
118/// | Symbol | Name                 | Definition        | Equivalent in 'au/d' |
119/// |--------|----------------------|-------------------|----------------------|
120/// | km/h   | Kilometer per Hour   | km/h              | 1.604300909344427e-7 |
121/// | m/s    | Meter per Second     | SI reference unit | 5.775483273639937e-7 |
122/// | c      | Speed of Light       | ls/s              | 173.14463267424034   |
123pub struct Speed {}