| 1 | /*! Lunar Dynamics |
| 2 | |
| 3 | Contains one main type, `Moon`, with methods for: |
| 4 | |
| 5 | * Location |
| 6 | * Distance |
| 7 | * Illuminated Fraction |
| 8 | * Phase Angle |
| 9 | * Angular Diameter |
| 10 | * Magnitude |
| 11 | * Parallax |
| 12 | */ |
| 13 | use craterust-analyzer cargo pracstro 1.1.1 crate/::{ |
| 14 | coordrust-analyzer cargo pracstro 1.1.1 coord/::{selfrust-analyzer cargo pracstro 1.1.1 coord/, Coordrust-analyzer cargo pracstro 1.1.1 coord/Coord#}, |
| 15 | solrust-analyzer cargo pracstro 1.1.1 sol/, timerust-analyzer cargo pracstro 1.1.1 time/, |
| 16 | }; |
| 17 | |
| 18 | /// Structure for the moons orbital properties at an epoch. |
| 19 | /// |
| 20 | /// There's only one moon, but having the data and routines all in one type is cleaner. |
| 21 | /// The data contained in this is floating point instead of the Time/Coordinate types provided because static |
| 22 | /// Time/Angle/Coordinate data using those types is unpleasant to construct. And because the code I've written before |
| 23 | /// works with floats. |
| 24 | #[deriverust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/derive:(Copyrust-analyzer cargo core https://github.com/rust-lang/rust/library/core marker/Copy:, Clonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core clone/Clone:)] |
| 25 | pub struct Moonrust-analyzer cargo pracstro 1.1.1 moon/Moon# { |
| 26 | /// The epoch on which this data is based off |
| 27 | pub epochrust-analyzer cargo pracstro 1.1.1 moon/Moon#epoch.: f64, |
| 28 | /// Mean Longitude |
| 29 | pub l0rust-analyzer cargo pracstro 1.1.1 moon/Moon#l0.: f64, |
| 30 | /// Mean Longitude of the node |
| 31 | pub n0rust-analyzer cargo pracstro 1.1.1 moon/Moon#n0.: f64, |
| 32 | /// Inclination |
| 33 | pub irust-analyzer cargo pracstro 1.1.1 moon/Moon#i.: timerust-analyzer cargo pracstro 1.1.1 time/::Anglerust-analyzer cargo pracstro 1.1.1 time/Angle#, |
| 34 | /// Eccentricity |
| 35 | pub erust-analyzer cargo pracstro 1.1.1 moon/Moon#e.: f64, |
| 36 | /// Semi-major axis |
| 37 | pub arust-analyzer cargo pracstro 1.1.1 moon/Moon#a.: f64, |
| 38 | /// Angular size at 1AU |
| 39 | pub theta0rust-analyzer cargo pracstro 1.1.1 moon/Moon#theta0.: timerust-analyzer cargo pracstro 1.1.1 time/::Anglerust-analyzer cargo pracstro 1.1.1 time/Angle#, |
| 40 | /// Parallax at 1AU |
| 41 | pub pi0rust-analyzer cargo pracstro 1.1.1 moon/Moon#pi0.: timerust-analyzer cargo pracstro 1.1.1 time/::Anglerust-analyzer cargo pracstro 1.1.1 time/Angle#, |
| 42 | } |
| 43 | |
| 44 | /// The moon at epoch January 1980 0.0 |
| 45 | pub const MOONrust-analyzer cargo pracstro 1.1.1 moon/MOON.: Moonrust-analyzer cargo pracstro 1.1.1 moon/Moon# = Moonrust-analyzer cargo pracstro 1.1.1 moon/Moon# { |
| 46 | epochrust-analyzer cargo pracstro 1.1.1 moon/Moon#epoch.: 2444238.5, // January 1980 0.0 |
| 47 | l0rust-analyzer cargo pracstro 1.1.1 moon/Moon#l0.: 64.975464, |
| 48 | n0rust-analyzer cargo pracstro 1.1.1 moon/Moon#n0.: 151.950429, |
| 49 | irust-analyzer cargo pracstro 1.1.1 moon/Moon#i.: timerust-analyzer cargo pracstro 1.1.1 time/::Anglerust-analyzer cargo pracstro 1.1.1 time/Angle#::from_degreesrust-analyzer cargo pracstro 1.1.1 time/impl#[Angle]from_degrees().(5.145396), |
| 50 | erust-analyzer cargo pracstro 1.1.1 moon/Moon#e.: 0.054900, |
| 51 | arust-analyzer cargo pracstro 1.1.1 moon/Moon#a.: 0.002569562, // AU |
| 52 | theta0rust-analyzer cargo pracstro 1.1.1 moon/Moon#theta0.: timerust-analyzer cargo pracstro 1.1.1 time/::Anglerust-analyzer cargo pracstro 1.1.1 time/Angle#::from_degreesrust-analyzer cargo pracstro 1.1.1 time/impl#[Angle]from_degrees().(0.0013312900722), |
| 53 | pi0rust-analyzer cargo pracstro 1.1.1 moon/Moon#pi0.: timerust-analyzer cargo pracstro 1.1.1 time/::Anglerust-analyzer cargo pracstro 1.1.1 time/Angle#::from_degreesrust-analyzer cargo pracstro 1.1.1 time/impl#[Angle]from_degrees().(0.0024428825934), |
| 54 | }; |
| 55 | |
| 56 | impl Moonrust-analyzer cargo pracstro 1.1.1 moon/Moon# { |
| 57 | /// Gets a ton of information about the moon that is used by other functions |
| 58 | /// |
| 59 | /// From moontool.c by John Walker |
| 60 | fn mooninforust-analyzer cargo pracstro 1.1.1 moon/impl#[Moon]mooninfo().(self, d: timerust-analyzer cargo pracstro 1.1.1 time/::Daterust-analyzer cargo pracstro 1.1.1 time/Date#) -> (timerust-analyzer cargo pracstro 1.1.1 time/::Anglerust-analyzer cargo pracstro 1.1.1 time/Angle#, coordrust-analyzer cargo pracstro 1.1.1 coord/::Coordrust-analyzer cargo pracstro 1.1.1 coord/Coord#, f64) { |
| 61 | /* Calculation of the Sun's position */ |
| 62 | let day = d.julianrust-analyzer cargo pracstro 1.1.1 time/impl#[Date]julian().() rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f64][`Sub<Self>`]sub().-rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f64][`Sub<Self>`]sub(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f64][`Sub<Self>`]sub().self.epochrust-analyzer cargo pracstro 1.1.1 moon/Moon#epoch.; /* Date within epoch */ |
| 63 | let m = timerust-analyzer cargo pracstro 1.1.1 time/::Anglerust-analyzer cargo pracstro 1.1.1 time/Angle#::from_degreesrust-analyzer cargo pracstro 1.1.1 time/impl#[Angle]from_degrees().(((360.0 rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f64][`Div<Self>`]div()./rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f64][`Div<Self>`]div(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f64][`Div<Self>`]div().365.2422) rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f64][`Mul<Self>`]mul().*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f64][`Mul<Self>`]mul(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f64][`Mul<Self>`]mul().day) rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f64][`Add<Self>`]add().+rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f64][`Add<Self>`]add(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f64][`Add<Self>`]add().278.833540 rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f64][`Sub<Self>`]sub().-rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f64][`Sub<Self>`]sub(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f64][`Sub<Self>`]sub().282.596403); /* Convert from perigee co-ordinates to epoch 1980.0 */ |
| 64 | let lambdasun = solrust-analyzer cargo pracstro 1.1.1 sol/::SUNrust-analyzer cargo pracstro 1.1.1 sol/SUN..locationrust-analyzer cargo pracstro 1.1.1 sol/impl#[Sun]location().(d).eclipticrust-analyzer cargo pracstro 1.1.1 coord/impl#[Coord]ecliptic().(d).0; |
| 65 | |
| 66 | // Moon's mean longitude |
| 67 | let ml = timerust-analyzer cargo pracstro 1.1.1 time/::Anglerust-analyzer cargo pracstro 1.1.1 time/Angle#::from_degreesrust-analyzer cargo pracstro 1.1.1 time/impl#[Angle]from_degrees().(13.1763966 rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f64][`Mul<Self>`]mul().*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f64][`Mul<Self>`]mul(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f64][`Mul<Self>`]mul().day rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f64][`Add<Self>`]add().+rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f64][`Add<Self>`]add(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f64][`Add<Self>`]add().self.l0rust-analyzer cargo pracstro 1.1.1 moon/Moon#l0.); |
| 68 | |
| 69 | // Moon's mean anomaly |
| 70 | let mm = timerust-analyzer cargo pracstro 1.1.1 time/::Anglerust-analyzer cargo pracstro 1.1.1 time/Angle#::from_degreesrust-analyzer cargo pracstro 1.1.1 time/impl#[Angle]from_degrees().(ml.degreesrust-analyzer cargo pracstro 1.1.1 time/impl#[Angle]degrees().() rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f64][`Sub<Self>`]sub().-rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f64][`Sub<Self>`]sub(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f64][`Sub<Self>`]sub().0.1114041 rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f64][`Mul<Self>`]mul().*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f64][`Mul<Self>`]mul(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f64][`Mul<Self>`]mul().day rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f64][`Sub<Self>`]sub().-rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f64][`Sub<Self>`]sub(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f64][`Sub<Self>`]sub().349.383063); /* 349: Mean longitude of the perigee at the epoch */ |
| 71 | |
| 72 | // Evection |
| 73 | let ev = 1.2739 rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f64][`Mul<Self>`]mul().*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f64][`Mul<Self>`]mul(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f64][`Mul<Self>`]mul().((ml rust-analyzer cargo pracstro 1.1.1 time/impl#[Angle][`Sub<Self>`]sub().-rust-analyzer cargo pracstro 1.1.1 time/impl#[Angle][`Sub<Self>`]sub(). rust-analyzer cargo pracstro 1.1.1 time/impl#[Angle][`Sub<Self>`]sub().lambdasun) rust-analyzer cargo pracstro 1.1.1 time/impl#[Angle][`Mul<f64>`]mul().*rust-analyzer cargo pracstro 1.1.1 time/impl#[Angle][`Mul<f64>`]mul(). rust-analyzer cargo pracstro 1.1.1 time/impl#[Angle][`Mul<f64>`]mul().2.0 rust-analyzer cargo pracstro 1.1.1 time/impl#[Angle][`Sub<Self>`]sub().-rust-analyzer cargo pracstro 1.1.1 time/impl#[Angle][`Sub<Self>`]sub(). rust-analyzer cargo pracstro 1.1.1 time/impl#[Angle][`Sub<Self>`]sub().mm).sinrust-analyzer cargo pracstro 1.1.1 time/impl#[Angle]sin().(); |
| 74 | |
| 75 | // Annual equation |
| 76 | let ae = 0.1858 rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f64][`Mul<Self>`]mul().*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f64][`Mul<Self>`]mul(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f64][`Mul<Self>`]mul().m.sinrust-analyzer cargo pracstro 1.1.1 time/impl#[Angle]sin().(); |
| 77 | |
| 78 | // Corrected anomaly |
| 79 | let mmp = timerust-analyzer cargo pracstro 1.1.1 time/::Anglerust-analyzer cargo pracstro 1.1.1 time/Angle#::from_degreesrust-analyzer cargo pracstro 1.1.1 time/impl#[Angle]from_degrees().(mm.degreesrust-analyzer cargo pracstro 1.1.1 time/impl#[Angle]degrees().() rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f64][`Add<Self>`]add().+rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f64][`Add<Self>`]add(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f64][`Add<Self>`]add().ev rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f64][`Sub<Self>`]sub().-rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f64][`Sub<Self>`]sub(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f64][`Sub<Self>`]sub().ae rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f64][`Sub<Self>`]sub().-rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f64][`Sub<Self>`]sub(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f64][`Sub<Self>`]sub().(0.37 rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f64][`Mul<Self>`]mul().*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f64][`Mul<Self>`]mul(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f64][`Mul<Self>`]mul().m.sinrust-analyzer cargo pracstro 1.1.1 time/impl#[Angle]sin().())); |
| 80 | |
| 81 | // Correction for the equation of the centre |
| 82 | let mec = timerust-analyzer cargo pracstro 1.1.1 time/::Anglerust-analyzer cargo pracstro 1.1.1 time/Angle#::from_degreesrust-analyzer cargo pracstro 1.1.1 time/impl#[Angle]from_degrees().(6.2886 rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f64][`Mul<Self>`]mul().*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f64][`Mul<Self>`]mul(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f64][`Mul<Self>`]mul().mmp.sinrust-analyzer cargo pracstro 1.1.1 time/impl#[Angle]sin().()); |
| 83 | |
| 84 | // Corrected longitude |
| 85 | let lp = timerust-analyzer cargo pracstro 1.1.1 time/::Anglerust-analyzer cargo pracstro 1.1.1 time/Angle#::from_degreesrust-analyzer cargo pracstro 1.1.1 time/impl#[Angle]from_degrees().( |
| 86 | ml.degreesrust-analyzer cargo pracstro 1.1.1 time/impl#[Angle]degrees().() rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f64][`Add<Self>`]add().+rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f64][`Add<Self>`]add(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f64][`Add<Self>`]add().ev rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f64][`Add<Self>`]add().+rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f64][`Add<Self>`]add(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f64][`Add<Self>`]add().(6.2886 rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f64][`Mul<Self>`]mul().*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f64][`Mul<Self>`]mul(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f64][`Mul<Self>`]mul().mmp.sinrust-analyzer cargo pracstro 1.1.1 time/impl#[Angle]sin().()) rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f64][`Sub<Self>`]sub().-rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f64][`Sub<Self>`]sub(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f64][`Sub<Self>`]sub().ae rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f64][`Add<Self>`]add().+rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f64][`Add<Self>`]add(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f64][`Add<Self>`]add().(0.214 rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f64][`Mul<Self>`]mul().*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f64][`Mul<Self>`]mul(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f64][`Mul<Self>`]mul().(mmp rust-analyzer cargo pracstro 1.1.1 time/impl#[Angle][`Mul<f64>`]mul().*rust-analyzer cargo pracstro 1.1.1 time/impl#[Angle][`Mul<f64>`]mul(). rust-analyzer cargo pracstro 1.1.1 time/impl#[Angle][`Mul<f64>`]mul().2.0).sinrust-analyzer cargo pracstro 1.1.1 time/impl#[Angle]sin().()), |
| 87 | ); |
| 88 | |
| 89 | // True longitude |
| 90 | let lpp = timerust-analyzer cargo pracstro 1.1.1 time/::Anglerust-analyzer cargo pracstro 1.1.1 time/Angle#::from_degreesrust-analyzer cargo pracstro 1.1.1 time/impl#[Angle]from_degrees().(lp.degreesrust-analyzer cargo pracstro 1.1.1 time/impl#[Angle]degrees().() rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f64][`Add<Self>`]add().+rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f64][`Add<Self>`]add(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f64][`Add<Self>`]add().(1.3166 rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f64][`Mul<Self>`]mul().*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f64][`Mul<Self>`]mul(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f64][`Mul<Self>`]mul().(lp rust-analyzer cargo pracstro 1.1.1 time/impl#[Angle][`Sub<Self>`]sub().-rust-analyzer cargo pracstro 1.1.1 time/impl#[Angle][`Sub<Self>`]sub(). rust-analyzer cargo pracstro 1.1.1 time/impl#[Angle][`Sub<Self>`]sub().lambdasun).sinrust-analyzer cargo pracstro 1.1.1 time/impl#[Angle]sin().())); |
| 91 | |
| 92 | // Corrected longitude of the node |
| 93 | let np = timerust-analyzer cargo pracstro 1.1.1 time/::Anglerust-analyzer cargo pracstro 1.1.1 time/Angle#::from_degreesrust-analyzer cargo pracstro 1.1.1 time/impl#[Angle]from_degrees().( |
| 94 | timerust-analyzer cargo pracstro 1.1.1 time/::Anglerust-analyzer cargo pracstro 1.1.1 time/Angle#::from_degreesrust-analyzer cargo pracstro 1.1.1 time/impl#[Angle]from_degrees().(self.n0rust-analyzer cargo pracstro 1.1.1 moon/Moon#n0. rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f64][`Sub<Self>`]sub().-rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f64][`Sub<Self>`]sub(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f64][`Sub<Self>`]sub().0.0529539 rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f64][`Mul<Self>`]mul().*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f64][`Mul<Self>`]mul(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f64][`Mul<Self>`]mul().day).degreesrust-analyzer cargo pracstro 1.1.1 time/impl#[Angle]degrees().() rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f64][`Sub<Self>`]sub().-rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f64][`Sub<Self>`]sub(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f64][`Sub<Self>`]sub().0.16 rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f64][`Mul<Self>`]mul().*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f64][`Mul<Self>`]mul(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f64][`Mul<Self>`]mul().m.sinrust-analyzer cargo pracstro 1.1.1 time/impl#[Angle]sin().(), |
| 95 | ); |
| 96 | |
| 97 | let lambdamoon = |
| 98 | timerust-analyzer cargo pracstro 1.1.1 time/::Anglerust-analyzer cargo pracstro 1.1.1 time/Angle#::from_radiansrust-analyzer cargo pracstro 1.1.1 time/impl#[Angle]from_radians().(((lpp rust-analyzer cargo pracstro 1.1.1 time/impl#[Angle][`Sub<Self>`]sub().-rust-analyzer cargo pracstro 1.1.1 time/impl#[Angle][`Sub<Self>`]sub(). rust-analyzer cargo pracstro 1.1.1 time/impl#[Angle][`Sub<Self>`]sub().np).sinrust-analyzer cargo pracstro 1.1.1 time/impl#[Angle]sin().() rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f64][`Mul<Self>`]mul().*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f64][`Mul<Self>`]mul(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f64][`Mul<Self>`]mul().self.irust-analyzer cargo pracstro 1.1.1 moon/Moon#i..cosrust-analyzer cargo pracstro 1.1.1 time/impl#[Angle]cos().()).atan2rust-analyzer cargo std https://github.com/rust-lang/rust/library/std f64/impl#[f64]atan2().((lpp rust-analyzer cargo pracstro 1.1.1 time/impl#[Angle][`Sub<Self>`]sub().-rust-analyzer cargo pracstro 1.1.1 time/impl#[Angle][`Sub<Self>`]sub(). rust-analyzer cargo pracstro 1.1.1 time/impl#[Angle][`Sub<Self>`]sub().np).cosrust-analyzer cargo pracstro 1.1.1 time/impl#[Angle]cos().())) |
| 99 | +rust-analyzer cargo pracstro 1.1.1 time/impl#[Angle][`Add<Self>`]add(). rust-analyzer cargo pracstro 1.1.1 time/impl#[Angle][`Add<Self>`]add().np; |
| 100 | let betamoon = timerust-analyzer cargo pracstro 1.1.1 time/::Anglerust-analyzer cargo pracstro 1.1.1 time/Angle#::asinrust-analyzer cargo pracstro 1.1.1 time/impl#[Angle]asin().((lpp rust-analyzer cargo pracstro 1.1.1 time/impl#[Angle][`Sub<Self>`]sub().-rust-analyzer cargo pracstro 1.1.1 time/impl#[Angle][`Sub<Self>`]sub(). rust-analyzer cargo pracstro 1.1.1 time/impl#[Angle][`Sub<Self>`]sub().np).sinrust-analyzer cargo pracstro 1.1.1 time/impl#[Angle]sin().() rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f64][`Mul<Self>`]mul().*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f64][`Mul<Self>`]mul(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f64][`Mul<Self>`]mul().self.irust-analyzer cargo pracstro 1.1.1 moon/Moon#i..sinrust-analyzer cargo pracstro 1.1.1 time/impl#[Angle]sin().()); |
| 101 | |
| 102 | let dist = (self.arust-analyzer cargo pracstro 1.1.1 moon/Moon#a. rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f64][`Mul<Self>`]mul().*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f64][`Mul<Self>`]mul(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f64][`Mul<Self>`]mul().(1.0 rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f64][`Sub<Self>`]sub().-rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f64][`Sub<Self>`]sub(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f64][`Sub<Self>`]sub().self.erust-analyzer cargo pracstro 1.1.1 moon/Moon#e. rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f64][`Mul<Self>`]mul().*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f64][`Mul<Self>`]mul(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f64][`Mul<Self>`]mul().self.erust-analyzer cargo pracstro 1.1.1 moon/Moon#e.)) rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f64][`Div<Self>`]div()./rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f64][`Div<Self>`]div(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f64][`Div<Self>`]div().(1.0 rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f64][`Add<Self>`]add().+rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f64][`Add<Self>`]add(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f64][`Add<Self>`]add().self.erust-analyzer cargo pracstro 1.1.1 moon/Moon#e. rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f64][`Mul<Self>`]mul().*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f64][`Mul<Self>`]mul(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f64][`Mul<Self>`]mul().(mmp rust-analyzer cargo pracstro 1.1.1 time/impl#[Angle][`Add<Self>`]add().+rust-analyzer cargo pracstro 1.1.1 time/impl#[Angle][`Add<Self>`]add(). rust-analyzer cargo pracstro 1.1.1 time/impl#[Angle][`Add<Self>`]add().mec).cosrust-analyzer cargo pracstro 1.1.1 time/impl#[Angle]cos().()); |
| 103 | |
| 104 | ( |
| 105 | // Age of the Moon in degrees |
| 106 | lpp rust-analyzer cargo pracstro 1.1.1 time/impl#[Angle][`Sub<Self>`]sub().-rust-analyzer cargo pracstro 1.1.1 time/impl#[Angle][`Sub<Self>`]sub(). rust-analyzer cargo pracstro 1.1.1 time/impl#[Angle][`Sub<Self>`]sub().lambdasun, |
| 107 | // Coordinates of the moon |
| 108 | coordrust-analyzer cargo pracstro 1.1.1 coord/::Coordrust-analyzer cargo pracstro 1.1.1 coord/Coord#::from_eclipticrust-analyzer cargo pracstro 1.1.1 coord/impl#[Coord]from_ecliptic().(lambdamoon, betamoon, d), |
| 109 | // Distance from earth |
| 110 | dist, |
| 111 | ) |
| 112 | } |
| 113 | |
| 114 | /// Gets the cartesian coordinates of the moon in AU |
| 115 | pub fn locationcartrust-analyzer cargo pracstro 1.1.1 moon/impl#[Moon]locationcart().(self, d: timerust-analyzer cargo pracstro 1.1.1 time/::Daterust-analyzer cargo pracstro 1.1.1 time/Date#) -> (f64, f64, f64) { |
| 116 | let (_, crd, dist) = self.mooninforust-analyzer cargo pracstro 1.1.1 moon/impl#[Moon]mooninfo().(d); |
| 117 | Coordrust-analyzer cargo pracstro 1.1.1 coord/Coord#::cartesianrust-analyzer cargo pracstro 1.1.1 coord/impl#[Coord]cartesian().(crd, dist) |
| 118 | } |
| 119 | |
| 120 | /// Returns age of phase in Days |
| 121 | pub fn phaseagerust-analyzer cargo pracstro 1.1.1 moon/impl#[Moon]phaseage().(self, d: timerust-analyzer cargo pracstro 1.1.1 time/::Daterust-analyzer cargo pracstro 1.1.1 time/Date#) -> f64 { |
| 122 | 29.53058868 rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f64][`Mul<Self>`]mul().*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f64][`Mul<Self>`]mul(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f64][`Mul<Self>`]mul().self.mooninforust-analyzer cargo pracstro 1.1.1 moon/impl#[Moon]mooninfo().(d).0.turnsrust-analyzer cargo pracstro 1.1.1 time/impl#[Angle]turns().() |
| 123 | } |
| 124 | |
| 125 | /// Returns the illuminated fraction of the Moons surface |
| 126 | pub fn illumfracrust-analyzer cargo pracstro 1.1.1 moon/impl#[Moon]illumfrac().(self, d: timerust-analyzer cargo pracstro 1.1.1 time/::Daterust-analyzer cargo pracstro 1.1.1 time/Date#) -> f64 { |
| 127 | (1.0 rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f64][`Sub<Self>`]sub().-rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f64][`Sub<Self>`]sub(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f64][`Sub<Self>`]sub().self.mooninforust-analyzer cargo pracstro 1.1.1 moon/impl#[Moon]mooninfo().(d).0.cosrust-analyzer cargo pracstro 1.1.1 time/impl#[Angle]cos().()) rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f64][`Div<Self>`]div()./rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f64][`Div<Self>`]div(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f64][`Div<Self>`]div().2.0 |
| 128 | } |
| 129 | |
| 130 | /// Returns the phase angle of the moon |
| 131 | pub fn phaseanglerust-analyzer cargo pracstro 1.1.1 moon/impl#[Moon]phaseangle().(self, d: timerust-analyzer cargo pracstro 1.1.1 time/::Daterust-analyzer cargo pracstro 1.1.1 time/Date#) -> timerust-analyzer cargo pracstro 1.1.1 time/::Anglerust-analyzer cargo pracstro 1.1.1 time/Angle# { |
| 132 | self.mooninforust-analyzer cargo pracstro 1.1.1 moon/impl#[Moon]mooninfo().(d).0 |
| 133 | } |
| 134 | /// Returns the coordinates of the moon |
| 135 | /// |
| 136 | /// This code has a low accuracy of around 5 degrees |
| 137 | pub fn locationrust-analyzer cargo pracstro 1.1.1 moon/impl#[Moon]location().(self, d: timerust-analyzer cargo pracstro 1.1.1 time/::Daterust-analyzer cargo pracstro 1.1.1 time/Date#) -> coordrust-analyzer cargo pracstro 1.1.1 coord/::Coordrust-analyzer cargo pracstro 1.1.1 coord/Coord# { |
| 138 | self.mooninforust-analyzer cargo pracstro 1.1.1 moon/impl#[Moon]mooninfo().(d).1 |
| 139 | } |
| 140 | |
| 141 | /// Returns the distance to the moon in AU |
| 142 | pub fn distancerust-analyzer cargo pracstro 1.1.1 moon/impl#[Moon]distance().(self, d: timerust-analyzer cargo pracstro 1.1.1 time/::Daterust-analyzer cargo pracstro 1.1.1 time/Date#) -> f64 { |
| 143 | self.mooninforust-analyzer cargo pracstro 1.1.1 moon/impl#[Moon]mooninfo().(d).2 |
| 144 | } |
| 145 | |
| 146 | /// Returns angular diameter of the planet at current time |
| 147 | pub fn angdiarust-analyzer cargo pracstro 1.1.1 moon/impl#[Moon]angdia().(self, d: timerust-analyzer cargo pracstro 1.1.1 time/::Daterust-analyzer cargo pracstro 1.1.1 time/Date#) -> timerust-analyzer cargo pracstro 1.1.1 time/::Anglerust-analyzer cargo pracstro 1.1.1 time/Angle# { |
| 148 | self.theta0rust-analyzer cargo pracstro 1.1.1 moon/Moon#theta0. rust-analyzer cargo pracstro 1.1.1 time/impl#[Angle][`Div<f64>`]div()./rust-analyzer cargo pracstro 1.1.1 time/impl#[Angle][`Div<f64>`]div(). rust-analyzer cargo pracstro 1.1.1 time/impl#[Angle][`Div<f64>`]div().self.distancerust-analyzer cargo pracstro 1.1.1 moon/impl#[Moon]distance().(d) |
| 149 | } |
| 150 | |
| 151 | /// Calculates the moons horizontal parallax |
| 152 | pub fn parallaxrust-analyzer cargo pracstro 1.1.1 moon/impl#[Moon]parallax().(self, d: timerust-analyzer cargo pracstro 1.1.1 time/::Daterust-analyzer cargo pracstro 1.1.1 time/Date#) -> timerust-analyzer cargo pracstro 1.1.1 time/::Anglerust-analyzer cargo pracstro 1.1.1 time/Angle# { |
| 153 | self.pi0rust-analyzer cargo pracstro 1.1.1 moon/Moon#pi0. rust-analyzer cargo pracstro 1.1.1 time/impl#[Angle][`Div<f64>`]div()./rust-analyzer cargo pracstro 1.1.1 time/impl#[Angle][`Div<f64>`]div(). rust-analyzer cargo pracstro 1.1.1 time/impl#[Angle][`Div<f64>`]div().self.distancerust-analyzer cargo pracstro 1.1.1 moon/impl#[Moon]distance().(d) |
| 154 | } |
| 155 | |
| 156 | /// Magnitude of the moon |
| 157 | pub fn magnituderust-analyzer cargo pracstro 1.1.1 moon/impl#[Moon]magnitude().(self, d: timerust-analyzer cargo pracstro 1.1.1 time/::Daterust-analyzer cargo pracstro 1.1.1 time/Date#) -> f64 { |
| 158 | 5.0 rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f64][`Mul<Self>`]mul().*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f64][`Mul<Self>`]mul(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f64][`Mul<Self>`]mul().(self.distancerust-analyzer cargo pracstro 1.1.1 moon/impl#[Moon]distance().(d) rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f64][`Div<Self>`]div()./rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f64][`Div<Self>`]div(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f64][`Div<Self>`]div().self.illumfracrust-analyzer cargo pracstro 1.1.1 moon/impl#[Moon]illumfrac().(d).sqrtrust-analyzer cargo std https://github.com/rust-lang/rust/library/std f64/impl#[f64]sqrt().()).log10rust-analyzer cargo std https://github.com/rust-lang/rust/library/std f64/impl#[f64]log10().() rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f64][`Add<Self>`]add().+rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f64][`Add<Self>`]add(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f64][`Add<Self>`]add().0.21 |
| 159 | } |
| 160 | } |
| 161 | |
| 162 | #[cfg(test)] |
| 163 | mod testsrust-analyzer cargo pracstro 1.1.1 moon/tests/ { |
| 164 | use superrust-analyzer cargo pracstro 1.1.1 moon/::*; |
| 165 | |
| 166 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 167 | fn test_moonlocationrust-analyzer cargo pracstro 1.1.1 moon/tests/test_moonlocation().() { |
| 168 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!( |
| 169 | MOONrust-analyzer cargo pracstro 1.1.1 moon/MOON..locationrust-analyzer cargo pracstro 1.1.1 moon/impl#[Moon]location().(timerust-analyzer cargo pracstro 1.1.1 time/::Daterust-analyzer cargo pracstro 1.1.1 time/Date#::from_julianrust-analyzer cargo pracstro 1.1.1 time/impl#[Date]from_julian().(2460748.554861)), |
| 170 | coordrust-analyzer cargo pracstro 1.1.1 coord/::Coordrust-analyzer cargo pracstro 1.1.1 coord/Coord#::from_equatorialrust-analyzer cargo pracstro 1.1.1 coord/impl#[Coord]from_equatorial().( |
| 171 | timerust-analyzer cargo pracstro 1.1.1 time/::Anglerust-analyzer cargo pracstro 1.1.1 time/Angle#::from_degminsecrust-analyzer cargo pracstro 1.1.1 time/impl#[Angle]from_degminsec().(172, 11, 15.7), |
| 172 | timerust-analyzer cargo pracstro 1.1.1 time/::Anglerust-analyzer cargo pracstro 1.1.1 time/Angle#::from_degminsecrust-analyzer cargo pracstro 1.1.1 time/impl#[Angle]from_degminsec().(3, 59, 15.2) |
| 173 | ) |
| 174 | ); |
| 175 | } |
| 176 | |
| 177 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 178 | fn test_moonphaserust-analyzer cargo pracstro 1.1.1 moon/tests/test_moonphase().() { |
| 179 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!( |
| 180 | MOONrust-analyzer cargo pracstro 1.1.1 moon/MOON..illumfracrust-analyzer cargo pracstro 1.1.1 moon/impl#[Moon]illumfrac().(timerust-analyzer cargo pracstro 1.1.1 time/::Daterust-analyzer cargo pracstro 1.1.1 time/Date#::from_calendarrust-analyzer cargo pracstro 1.1.1 time/impl#[Date]from_calendar().( |
| 181 | 2025, |
| 182 | 03, |
| 183 | 29, |
| 184 | timerust-analyzer cargo pracstro 1.1.1 time/::Anglerust-analyzer cargo pracstro 1.1.1 time/Angle#::defaultrust-analyzer cargo pracstro 1.1.1 time/impl#[Angle][Default]default().() |
| 185 | )), |
| 186 | 0.002799062630499616 |
| 187 | ); |
| 188 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!( |
| 189 | MOONrust-analyzer cargo pracstro 1.1.1 moon/MOON..illumfracrust-analyzer cargo pracstro 1.1.1 moon/impl#[Moon]illumfrac().(timerust-analyzer cargo pracstro 1.1.1 time/::Daterust-analyzer cargo pracstro 1.1.1 time/Date#::from_calendarrust-analyzer cargo pracstro 1.1.1 time/impl#[Date]from_calendar().( |
| 190 | 2025, |
| 191 | 04, |
| 192 | 09, |
| 193 | timerust-analyzer cargo pracstro 1.1.1 time/::Anglerust-analyzer cargo pracstro 1.1.1 time/Angle#::defaultrust-analyzer cargo pracstro 1.1.1 time/impl#[Angle][Default]default().() |
| 194 | )), |
| 195 | 0.8694887493109439 |
| 196 | ); |
| 197 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!( |
| 198 | MOONrust-analyzer cargo pracstro 1.1.1 moon/MOON..magnituderust-analyzer cargo pracstro 1.1.1 moon/impl#[Moon]magnitude().(timerust-analyzer cargo pracstro 1.1.1 time/::Daterust-analyzer cargo pracstro 1.1.1 time/Date#::from_calendarrust-analyzer cargo pracstro 1.1.1 time/impl#[Date]from_calendar().( |
| 199 | 2024, |
| 200 | 12, |
| 201 | 25, |
| 202 | timerust-analyzer cargo pracstro 1.1.1 time/::Anglerust-analyzer cargo pracstro 1.1.1 time/Angle#::defaultrust-analyzer cargo pracstro 1.1.1 time/impl#[Angle][Default]default().() |
| 203 | )), |
| 204 | -rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f64][Neg]neg().11.366493493867907 |
| 205 | ); |
| 206 | } |
| 207 | |
| 208 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 209 | fn test_moondistrust-analyzer cargo pracstro 1.1.1 moon/tests/test_moondist().() { |
| 210 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!( |
| 211 | MOONrust-analyzer cargo pracstro 1.1.1 moon/MOON..distancerust-analyzer cargo pracstro 1.1.1 moon/impl#[Moon]distance().(timerust-analyzer cargo pracstro 1.1.1 time/::Daterust-analyzer cargo pracstro 1.1.1 time/Date#::from_julianrust-analyzer cargo pracstro 1.1.1 time/impl#[Date]from_julian().(2460748.467894)), |
| 212 | 0.0026765709280575905 |
| 213 | ); |
| 214 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!( |
| 215 | MOONrust-analyzer cargo pracstro 1.1.1 moon/MOON..angdiarust-analyzer cargo pracstro 1.1.1 moon/impl#[Moon]angdia().(timerust-analyzer cargo pracstro 1.1.1 time/::Daterust-analyzer cargo pracstro 1.1.1 time/Date#::from_julianrust-analyzer cargo pracstro 1.1.1 time/impl#[Date]from_julian().(2460748.467894)), |
| 216 | timerust-analyzer cargo pracstro 1.1.1 time/::Anglerust-analyzer cargo pracstro 1.1.1 time/Angle#::from_degreesrust-analyzer cargo pracstro 1.1.1 time/impl#[Angle]from_degrees().(0.499999999) |
| 217 | ); |
| 218 | } |
| 219 | } |