pub struct Moon {
pub epoch: f64,
pub l0: f64,
pub n0: f64,
pub i: Angle,
pub e: f64,
pub a: f64,
pub theta0: Angle,
pub pi0: Angle,
}Expand description
Structure for the moons orbital properties at an epoch.
There’s only one moon, but having the data and routines all in one type is cleaner. The data contained in this is floating point instead of the Time/Coordinate types provided because static Time/Angle/Coordinate data using those types is unpleasant to construct. And because the code I’ve written before works with floats.
Fields§
§epoch: f64The epoch on which this data is based off
l0: f64Mean Longitude
n0: f64Mean Longitude of the node
i: AngleInclination
e: f64Eccentricity
a: f64Semi-major axis
theta0: AngleAngular size at 1AU
pi0: AngleParallax at 1AU
Implementations§
Source§impl Moon
impl Moon
Sourcepub fn locationcart(self, d: Date) -> (f64, f64, f64)
pub fn locationcart(self, d: Date) -> (f64, f64, f64)
Gets the cartesian coordinates of the moon in AU
Sourcepub fn phaseage(self, d: Date) -> f64
pub fn phaseage(self, d: Date) -> f64
Returns age of phase in Days
Examples found in repository?
examples/mprintf.rs (line 34)
31fn main() {
32 let p = (
33 moon::MOON.illumfrac(time::Date::now()),
34 moon::MOON.phaseage(time::Date::now()),
35 );
36 println!(
37 "{} {} ({:.2}%)",
38 PNAMES[phaseidx(p.0, p.1)],
39 EMOJIS[phaseidx(p.0, p.1)],
40 p.0 * 100.0
41 );
42}Sourcepub fn illumfrac(self, d: Date) -> f64
pub fn illumfrac(self, d: Date) -> f64
Returns the illuminated fraction of the Moons surface
Examples found in repository?
examples/mprintf.rs (line 33)
31fn main() {
32 let p = (
33 moon::MOON.illumfrac(time::Date::now()),
34 moon::MOON.phaseage(time::Date::now()),
35 );
36 println!(
37 "{} {} ({:.2}%)",
38 PNAMES[phaseidx(p.0, p.1)],
39 EMOJIS[phaseidx(p.0, p.1)],
40 p.0 * 100.0
41 );
42}More examples
examples/speed.rs (line 28)
11fn main() {
12 let n = 40000;
13 println!("Test,Mean (n={}),Full", n);
14
15 run_test("Control (NOP)", n, || ());
16 run_test("Current time", n, || {
17 time::Date::now();
18 });
19 fn ephem() {
20 let now = time::Date::now();
21 for p in sol::PLANETS {
22 let (ra, de) = p.location(now).equatorial();
23 (ra.clock(), de.to_latitude().degminsec());
24 }
25 }
26 run_test("Full ephemeris", n, ephem);
27 run_test("Moon Phase", n, || {
28 moon::MOON.illumfrac(time::Date::now());
29 });
30}Sourcepub fn phaseangle(self, d: Date) -> Angle
pub fn phaseangle(self, d: Date) -> Angle
Returns the phase angle of the moon
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Moon
impl RefUnwindSafe for Moon
impl Send for Moon
impl Sync for Moon
impl Unpin for Moon
impl UnsafeUnpin for Moon
impl UnwindSafe for Moon
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more