Skip to main content

Moon

Struct Moon 

Source
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: f64

The epoch on which this data is based off

§l0: f64

Mean Longitude

§n0: f64

Mean Longitude of the node

§i: Angle

Inclination

§e: f64

Eccentricity

§a: f64

Semi-major axis

§theta0: Angle

Angular size at 1AU

§pi0: Angle

Parallax at 1AU

Implementations§

Source§

impl Moon

Source

pub fn locationcart(self, d: Date) -> (f64, f64, f64)

Gets the cartesian coordinates of the moon in AU

Source

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}
Source

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
Hide additional 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}
Source

pub fn phaseangle(self, d: Date) -> Angle

Returns the phase angle of the moon

Source

pub fn location(self, d: Date) -> Coord

Returns the coordinates of the moon

This code has a low accuracy of around 5 degrees

Source

pub fn distance(self, d: Date) -> f64

Returns the distance to the moon in AU

Source

pub fn angdia(self, d: Date) -> Angle

Returns angular diameter of the planet at current time

Source

pub fn parallax(self, d: Date) -> Angle

Calculates the moons horizontal parallax

Source

pub fn magnitude(self, d: Date) -> f64

Magnitude of the moon

Trait Implementations§

Source§

impl Clone for Moon

Source§

fn clone(&self) -> Moon

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Copy for Moon

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> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.