Debian Codegraph @

src/coord.rs

raw symbols SCIP
1 //! Coordinate handling
2 //!
3 //! This module contains one type, [`Coord`]. That has methods to convert two and from several
4 //! different coordinate systems. Mainly:
5 //! - Equatorial (Hour Angle, Declination)
6 //! - Horizon (Azimuth, Altitude)
7 //! - Ecliptic (Beta, Lambda)
8 //!
9 //! This type also contains algorithms for converting from Cartesian (rectangular) coordinates, rise and set times, distance between angles, etc.
10
11 use craterust-analyzer cargo pracstro 1.1.1 crate/::timerust-analyzer cargo pracstro 1.1.1 time/::*;
12
13 /// Gets the mean obliquity of the ecliptic at a certain date
14 pub fn mean_obliquity_eclrust-analyzer cargo pracstro 1.1.1 coord/mean_obliquity_ecl().(d: Daterust-analyzer cargo pracstro 1.1.1 time/Date#) -> Anglerust-analyzer cargo pracstro 1.1.1 time/Angle# {
15 let t = d.centuriesrust-analyzer cargo pracstro 1.1.1 time/impl#[Date]centuries().();
16 Anglerust-analyzer cargo pracstro 1.1.1 time/Angle#::from_degreesrust-analyzer cargo pracstro 1.1.1 time/impl#[Angle]from_degrees().(
17 23.439_292 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().((46.815 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().t 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.0006 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().(t 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().t) 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.00181 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().(t 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().t 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().t)) 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().3600.0),
18 )
19 }
20
21 /**
22 Pair of angles, Representing "How far up" and "How far round"
23
24 | Property | Latitude | Longitude | Depends On | To Method | From Method |
25 |-------------------|-------------------|---------------------|---------------------------------|------------------------|-----------------------------|
26 | Equatorial | Declination (δ) | Right Ascension (α) | | [`Coord::equatorial()`]| [`Coord::from_equatorial()`]|
27 | Horizontal | Altitude (a) | Azimuth (A) | Date, Time, Latitude, Longitude | [`Coord::horizon()`] | [`Coord::from_horizon()`] |
28 | Ecliptic | Ecl. Latitude (β) | Ecl. Longitude (λ) | Date[^1] | [`Coord::ecliptic()`] | [`Coord::from_ecliptic()`] |
29 | Cartesian | N/A (3D system) | N/A (3D system) | Distance | [`Coord::cartesian()`] | [`Coord::from_cartesian()`] |
30
31 Additional Methods:
32 * Distance between coordinates: [`Coord::dist()`]
33 * Rise and set times of a coordinate in the sky [`Coord::riseset()`]
34 * Precession [`Coord::precess()`]
35
36 [^1]: The plane of the ecliptic varies slightly with perturbations in the orbit and inclination of the earth.
37 */
38 #[deriverust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/derive:(Debugrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/macros/Debug:, PartialEqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/PartialEq:, Clonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core clone/Clone:, Copyrust-analyzer cargo core https://github.com/rust-lang/rust/library/core marker/Copy:, Defaultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core default/Default:)]
39 pub struct Coordrust-analyzer cargo pracstro 1.1.1 coord/Coord#(Anglerust-analyzer cargo pracstro 1.1.1 time/Angle#, Anglerust-analyzer cargo pracstro 1.1.1 time/Angle#);
40 impl Coordrust-analyzer cargo pracstro 1.1.1 coord/Coord# {
41 /// Right Ascension and Declination
42 pub const fn equatorialrust-analyzer cargo pracstro 1.1.1 coord/impl#[Coord]equatorial().(self) -> (Anglerust-analyzer cargo pracstro 1.1.1 time/Angle#, Anglerust-analyzer cargo pracstro 1.1.1 time/Angle#) {
43 (self.0rust-analyzer cargo pracstro 1.1.1 coord/Coord#0., self.1rust-analyzer cargo pracstro 1.1.1 coord/Coord#1.)
44 }
45 /// Right Ascension and Declination
46 pub const fn from_equatorialrust-analyzer cargo pracstro 1.1.1 coord/impl#[Coord]from_equatorial().(x: Anglerust-analyzer cargo pracstro 1.1.1 time/Angle#, y: Anglerust-analyzer cargo pracstro 1.1.1 time/Angle#) -> Selfrust-analyzer cargo pracstro 1.1.1 coord/impl#[Coord] {
47 Coordrust-analyzer cargo pracstro 1.1.1 coord/Coord#(x, y)
48 }
49
50 /// Azimuth and Altitude, dependent on location and time
51 ///
52 /// From Practical Astronomy with Your Calculator, Although similar algorithms exist in other sources
53 pub fn horizonrust-analyzer cargo pracstro 1.1.1 coord/impl#[Coord]horizon().(self, date: Daterust-analyzer cargo pracstro 1.1.1 time/Date#, lati: Anglerust-analyzer cargo pracstro 1.1.1 time/Angle#, longi: Anglerust-analyzer cargo pracstro 1.1.1 time/Angle#) -> (Anglerust-analyzer cargo pracstro 1.1.1 time/Angle#, Anglerust-analyzer cargo pracstro 1.1.1 time/Angle#) {
54 let (ra, de) = self.equatorialrust-analyzer cargo pracstro 1.1.1 coord/impl#[Coord]equatorial().();
55 let ha = date.timerust-analyzer cargo pracstro 1.1.1 time/impl#[Date]time().().gstrust-analyzer cargo pracstro 1.1.1 time/impl#[Angle]gst().(date) 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().longi 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().ra;
56 let alt = Anglerust-analyzer cargo pracstro 1.1.1 time/Angle#::asinrust-analyzer cargo pracstro 1.1.1 time/impl#[Angle]asin().(de.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().lati.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][`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().de.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][`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().lati.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][`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().ha.cosrust-analyzer cargo pracstro 1.1.1 time/impl#[Angle]cos().());
57 let azip = Anglerust-analyzer cargo pracstro 1.1.1 time/Angle#::acosrust-analyzer cargo pracstro 1.1.1 time/impl#[Angle]acos().((de.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().lati.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().alt.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][`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().(lati.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][`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().alt.cosrust-analyzer cargo pracstro 1.1.1 time/impl#[Angle]cos().()));
58 let azi = match ha.sinrust-analyzer cargo pracstro 1.1.1 time/impl#[Angle]sin().() rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[f64][`PartialOrd<Self>`]lt().<rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[f64][`PartialOrd<Self>`]lt(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[f64][`PartialOrd<Self>`]lt().0.0 {
59 true => azip,
60 false => 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][`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().azip.degreesrust-analyzer cargo pracstro 1.1.1 time/impl#[Angle]degrees().()),
61 };
62 (azi, alt)
63 }
64 /// Azimuth and Altitude, dependent on location, and time
65 ///
66 /// From Practical Astronomy with Your Calculator, Although similar algorithms exist in other sources
67 pub fn from_horizonrust-analyzer cargo pracstro 1.1.1 coord/impl#[Coord]from_horizon().(azi: Anglerust-analyzer cargo pracstro 1.1.1 time/Angle#, alt: Anglerust-analyzer cargo pracstro 1.1.1 time/Angle#, date: Daterust-analyzer cargo pracstro 1.1.1 time/Date#, lati: Anglerust-analyzer cargo pracstro 1.1.1 time/Angle#, longi: Anglerust-analyzer cargo pracstro 1.1.1 time/Angle#) -> Selfrust-analyzer cargo pracstro 1.1.1 coord/impl#[Coord] {
68 let de = Anglerust-analyzer cargo pracstro 1.1.1 time/Angle#::asinrust-analyzer cargo pracstro 1.1.1 time/impl#[Angle]asin().(alt.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().lati.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][`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().alt.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][`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().lati.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][`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().azi.cosrust-analyzer cargo pracstro 1.1.1 time/impl#[Angle]cos().());
69 let hap = Anglerust-analyzer cargo pracstro 1.1.1 time/Angle#::acosrust-analyzer cargo pracstro 1.1.1 time/impl#[Angle]acos().((alt.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().lati.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().de.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][`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().(lati.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][`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().de.cosrust-analyzer cargo pracstro 1.1.1 time/impl#[Angle]cos().()));
70 let ha = match azi.sinrust-analyzer cargo pracstro 1.1.1 time/impl#[Angle]sin().() rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[f64][`PartialOrd<Self>`]lt().<rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[f64][`PartialOrd<Self>`]lt(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[f64][`PartialOrd<Self>`]lt().0.0 {
71 true => hap,
72 false => 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][`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().hap.degreesrust-analyzer cargo pracstro 1.1.1 time/impl#[Angle]degrees().()),
73 };
74 Coordrust-analyzer cargo pracstro 1.1.1 coord/Coord#::from_equatorialrust-analyzer cargo pracstro 1.1.1 coord/impl#[Coord]from_equatorial().(date.timerust-analyzer cargo pracstro 1.1.1 time/impl#[Date]time().().gstrust-analyzer cargo pracstro 1.1.1 time/impl#[Angle]gst().(date) 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().longi 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().ha, de)
75 }
76
77 /// Used in solar calculations, based on the plane of the orbit of the earth
78 ///
79 /// From Practical Astronomy with Your Calculator, Although similar algorithms exist in other sources
80 pub fn eclipticrust-analyzer cargo pracstro 1.1.1 coord/impl#[Coord]ecliptic().(self, d: Daterust-analyzer cargo pracstro 1.1.1 time/Date#) -> (Anglerust-analyzer cargo pracstro 1.1.1 time/Angle#, Anglerust-analyzer cargo pracstro 1.1.1 time/Angle#) {
81 let (ra, de) = self.equatorialrust-analyzer cargo pracstro 1.1.1 coord/impl#[Coord]equatorial().();
82 let e = mean_obliquity_eclrust-analyzer cargo pracstro 1.1.1 coord/mean_obliquity_ecl().(d);
83 let beta = Anglerust-analyzer cargo pracstro 1.1.1 time/Angle#::asinrust-analyzer cargo pracstro 1.1.1 time/impl#[Angle]asin().(de.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().e.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][`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().de.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][`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().e.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().ra.sinrust-analyzer cargo pracstro 1.1.1 time/impl#[Angle]sin().());
84 let y = ra.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().e.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][`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().de.tanrust-analyzer cargo pracstro 1.1.1 time/impl#[Angle]tan().() 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().e.sinrust-analyzer cargo pracstro 1.1.1 time/impl#[Angle]sin().();
85 let x = ra.cosrust-analyzer cargo pracstro 1.1.1 time/impl#[Angle]cos().();
86 let lambda = Anglerust-analyzer cargo pracstro 1.1.1 time/Angle#::atan2rust-analyzer cargo pracstro 1.1.1 time/impl#[Angle]atan2().(y, x);
87 (lambda, beta)
88 }
89 /// Used in solar calculations, based on the plane of the orbit of the earth
90 ///
91 /// From Practical Astronomy with Your Calculator, Although similar algorithms exist in other sources
92 pub fn from_eclipticrust-analyzer cargo pracstro 1.1.1 coord/impl#[Coord]from_ecliptic().(lambda: Anglerust-analyzer cargo pracstro 1.1.1 time/Angle#, beta: Anglerust-analyzer cargo pracstro 1.1.1 time/Angle#, d: Daterust-analyzer cargo pracstro 1.1.1 time/Date#) -> Selfrust-analyzer cargo pracstro 1.1.1 coord/impl#[Coord] {
93 let e = mean_obliquity_eclrust-analyzer cargo pracstro 1.1.1 coord/mean_obliquity_ecl().(d);
94 let de = Anglerust-analyzer cargo pracstro 1.1.1 time/Angle#::asinrust-analyzer cargo pracstro 1.1.1 time/impl#[Angle]asin().(beta.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().e.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][`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().beta.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][`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().e.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().lambda.sinrust-analyzer cargo pracstro 1.1.1 time/impl#[Angle]sin().());
95 let ra = Anglerust-analyzer cargo pracstro 1.1.1 time/Angle#::atan2rust-analyzer cargo pracstro 1.1.1 time/impl#[Angle]atan2().(lambda.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().e.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][`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().beta.tanrust-analyzer cargo pracstro 1.1.1 time/impl#[Angle]tan().() 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().e.sinrust-analyzer cargo pracstro 1.1.1 time/impl#[Angle]sin().(), lambda.cosrust-analyzer cargo pracstro 1.1.1 time/impl#[Angle]cos().());
96 Coordrust-analyzer cargo pracstro 1.1.1 coord/Coord#::from_equatorialrust-analyzer cargo pracstro 1.1.1 coord/impl#[Coord]from_equatorial().(ra, de)
97 }
98
99 /// Convert 3D Rectangular Coordinates to 2D Polar Coordinates
100 ///
101 /// This does not retain the distance to the object
102 pub fn from_cartesianrust-analyzer cargo pracstro 1.1.1 coord/impl#[Coord]from_cartesian().(x: f64, y: f64, z: f64) -> Selfrust-analyzer cargo pracstro 1.1.1 coord/impl#[Coord] {
103 let (tx, ty, tz) = (x, y, z);
104 let r = (tx 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().tx 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().ty 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().ty 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().tz 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().tz).sqrtrust-analyzer cargo std https://github.com/rust-lang/rust/library/std f64/impl#[f64]sqrt().();
105 let l = Anglerust-analyzer cargo pracstro 1.1.1 time/Angle#::atan2rust-analyzer cargo pracstro 1.1.1 time/impl#[Angle]atan2().(ty, tx);
106 let t2 = Anglerust-analyzer cargo pracstro 1.1.1 time/Angle#::from_radiansrust-analyzer cargo pracstro 1.1.1 time/impl#[Angle]from_radians().(0.5 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().stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::f64rust-analyzer cargo std https://github.com/rust-lang/rust/library/std f64/::constsrust-analyzer cargo core https://github.com/rust-lang/rust/library/core f64/consts/::PIrust-analyzer cargo core https://github.com/rust-lang/rust/library/core f64/consts/PI. 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().(tz 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().r).acosrust-analyzer cargo std https://github.com/rust-lang/rust/library/std f64/impl#[f64]acos().());
107
108 Coordrust-analyzer cargo pracstro 1.1.1 coord/Coord#::from_equatorialrust-analyzer cargo pracstro 1.1.1 coord/impl#[Coord]from_equatorial().(l, t2)
109 }
110
111 /// Convert 2D Polar into 3D rectangular, depends on distance
112 pub fn cartesianrust-analyzer cargo pracstro 1.1.1 coord/impl#[Coord]cartesian().(self, dist: f64) -> (f64, f64, f64) {
113 let (lat, long) = self.equatorialrust-analyzer cargo pracstro 1.1.1 coord/impl#[Coord]equatorial().();
114 let x = dist 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().lat.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][`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().long.cosrust-analyzer cargo pracstro 1.1.1 time/impl#[Angle]cos().();
115 let y = dist 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().lat.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][`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().long.sinrust-analyzer cargo pracstro 1.1.1 time/impl#[Angle]sin().();
116 let z = dist 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().lat.sinrust-analyzer cargo pracstro 1.1.1 time/impl#[Angle]sin().();
117
118 (x, y, z)
119 }
120
121 /// Returns the angle between two objects
122 pub fn distrust-analyzer cargo pracstro 1.1.1 coord/impl#[Coord]dist().(self, from: Selfrust-analyzer cargo pracstro 1.1.1 coord/impl#[Coord]) -> Anglerust-analyzer cargo pracstro 1.1.1 time/Angle# {
123 let ((a1, d1), (a2, d2)) = (self.equatorialrust-analyzer cargo pracstro 1.1.1 coord/impl#[Coord]equatorial().(), from.equatorialrust-analyzer cargo pracstro 1.1.1 coord/impl#[Coord]equatorial().());
124 Anglerust-analyzer cargo pracstro 1.1.1 time/Angle#::acosrust-analyzer cargo pracstro 1.1.1 time/impl#[Angle]acos().(d1.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().d2.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][`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().d1.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][`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().d2.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][`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().(a1 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().a2).cosrust-analyzer cargo pracstro 1.1.1 time/impl#[Angle]cos().())
125 }
126 /// Returns (Rise, Set) UT, This function will fail for locations in the sky that never appear over the horizon
127 ///
128 /// From Practical Astronomy with Your Calculator, Although similar algorithms exist in other sources
129 pub fn risesetrust-analyzer cargo pracstro 1.1.1 coord/impl#[Coord]riseset().(self, date: Daterust-analyzer cargo pracstro 1.1.1 time/Date#, lati: Anglerust-analyzer cargo pracstro 1.1.1 time/Angle#, longi: Anglerust-analyzer cargo pracstro 1.1.1 time/Angle#) -> Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<(Anglerust-analyzer cargo pracstro 1.1.1 time/Angle#, Anglerust-analyzer cargo pracstro 1.1.1 time/Angle#)> {
130 let (ra, de) = self.equatorialrust-analyzer cargo pracstro 1.1.1 coord/impl#[Coord]equatorial().();
131 let ar = Anglerust-analyzer cargo pracstro 1.1.1 time/Angle#::acosrust-analyzer cargo pracstro 1.1.1 time/impl#[Angle]acos().(de.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][`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().lati.cosrust-analyzer cargo pracstro 1.1.1 time/impl#[Angle]cos().());
132 let h = Anglerust-analyzer cargo pracstro 1.1.1 time/Angle#::acosrust-analyzer cargo pracstro 1.1.1 time/impl#[Angle]acos().(-rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f64][Neg]neg().lati.tanrust-analyzer cargo pracstro 1.1.1 time/impl#[Angle]tan().() 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().de.tanrust-analyzer cargo pracstro 1.1.1 time/impl#[Angle]tan().());
133 if h.radiansrust-analyzer cargo pracstro 1.1.1 time/impl#[Angle]radians().().is_nanrust-analyzer cargo core https://github.com/rust-lang/rust/library/core f64/impl#[f64]is_nan().() || ar.radiansrust-analyzer cargo pracstro 1.1.1 time/impl#[Angle]radians().().is_nanrust-analyzer cargo core https://github.com/rust-lang/rust/library/core f64/impl#[f64]is_nan().() {
134 return Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#;
135 }
136 let lsts = (ra 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().h 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().longi).ungstrust-analyzer cargo pracstro 1.1.1 time/impl#[Angle]ungst().(date);
137 let lstr = (ra 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().h 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().longi).ungstrust-analyzer cargo pracstro 1.1.1 time/impl#[Angle]ungst().(date);
138 Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#((lsts, lstr))
139 }
140
141 /// (Roughly) Accounts for precession in coordinates.
142 pub fn precessrust-analyzer cargo pracstro 1.1.1 coord/impl#[Coord]precess().(self, epoch: Daterust-analyzer cargo pracstro 1.1.1 time/Date#, d: Daterust-analyzer cargo pracstro 1.1.1 time/Date#) -> Selfrust-analyzer cargo pracstro 1.1.1 coord/impl#[Coord] {
143 let (ra, de) = self.equatorialrust-analyzer cargo pracstro 1.1.1 coord/impl#[Coord]equatorial().();
144 let diff = (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().epoch.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][`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.25;
145 let m =
146 Anglerust-analyzer cargo pracstro 1.1.1 time/Angle#::from_clockrust-analyzer cargo pracstro 1.1.1 time/impl#[Angle]from_clock().(0, 0, 3.07234) 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().Anglerust-analyzer cargo pracstro 1.1.1 time/Angle#::from_clockrust-analyzer cargo pracstro 1.1.1 time/impl#[Angle]from_clock().(0, 0, 0.00186) 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().epoch.centuriesrust-analyzer cargo pracstro 1.1.1 time/impl#[Date]centuries().();
147 let n = Anglerust-analyzer cargo pracstro 1.1.1 time/Angle#::from_degminsecrust-analyzer cargo pracstro 1.1.1 time/impl#[Angle]from_degminsec().(0, 0, 20.0468)
148 +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().Anglerust-analyzer cargo pracstro 1.1.1 time/Angle#::from_degminsecrust-analyzer cargo pracstro 1.1.1 time/impl#[Angle]from_degminsec().(0, 0, 0.0085) 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().epoch.centuriesrust-analyzer cargo pracstro 1.1.1 time/impl#[Date]centuries().();
149 let deltara = m.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().n.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][`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().ra.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().de.tanrust-analyzer cargo pracstro 1.1.1 time/impl#[Angle]tan().();
150 let deltade = n.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][`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().ra.cosrust-analyzer cargo pracstro 1.1.1 time/impl#[Angle]cos().();
151 Coordrust-analyzer cargo pracstro 1.1.1 coord/Coord#::from_equatorialrust-analyzer cargo pracstro 1.1.1 coord/impl#[Coord]from_equatorial().(
152 ra 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().Anglerust-analyzer cargo pracstro 1.1.1 time/Angle#::from_degreesrust-analyzer cargo pracstro 1.1.1 time/impl#[Angle]from_degrees().(deltara 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().diff),
153 de 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().Anglerust-analyzer cargo pracstro 1.1.1 time/Angle#::from_degreesrust-analyzer cargo pracstro 1.1.1 time/impl#[Angle]from_degrees().(deltade 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().diff),
154 )
155 }
156 }
157
158 #[cfg(test)]
159 mod testsrust-analyzer cargo pracstro 1.1.1 coord/tests/ {
160 use superrust-analyzer cargo pracstro 1.1.1 coord/::*;
161
162 // Many of these tests do not conform with data you can pull out of stellarium/other tools, they are correct nonetheless.
163 // * How do you know?: By personal confirmation of the result data with other resources
164 // * Then how can I use these functions?: In conjunction with the functions for correction (procession, nutation, abberation, refraction)
165 // Note that even without correction, these tests are almost always within 16' (half the moons diameter).
166 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
167 fn test_horizrust-analyzer cargo pracstro 1.1.1 coord/tests/test_horiz().() {
168 let arcturus = Coordrust-analyzer cargo pracstro 1.1.1 coord/Coord#::from_equatorialrust-analyzer cargo pracstro 1.1.1 coord/impl#[Coord]from_equatorial().(
169 Anglerust-analyzer cargo pracstro 1.1.1 time/Angle#::from_clockrust-analyzer cargo pracstro 1.1.1 time/impl#[Angle]from_clock().(14, 16, 50.0),
170 Anglerust-analyzer cargo pracstro 1.1.1 time/Angle#::from_degminsecrust-analyzer cargo pracstro 1.1.1 time/impl#[Angle]from_degminsec().(19, 02, 50.1),
171 );
172 let sirius = Coordrust-analyzer cargo pracstro 1.1.1 coord/Coord#::from_equatorialrust-analyzer cargo pracstro 1.1.1 coord/impl#[Coord]from_equatorial().(
173 Anglerust-analyzer cargo pracstro 1.1.1 time/Angle#::from_clockrust-analyzer cargo pracstro 1.1.1 time/impl#[Angle]from_clock().(6, 46, 13.1),
174 Anglerust-analyzer cargo pracstro 1.1.1 time/Angle#::from_degminsecrust-analyzer cargo pracstro 1.1.1 time/impl#[Angle]from_degminsec().(-rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i16][Neg]neg().16, 45, 06.8),
175 );
176 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(
177 arcturus.horizonrust-analyzer cargo pracstro 1.1.1 coord/impl#[Coord]horizon().(
178 Daterust-analyzer cargo pracstro 1.1.1 time/Date#::from_calendarrust-analyzer cargo pracstro 1.1.1 time/impl#[Date]from_calendar().(2025, 3, 10, Anglerust-analyzer cargo pracstro 1.1.1 time/Angle#::from_clockrust-analyzer cargo pracstro 1.1.1 time/impl#[Angle]from_clock().(19, 52, 25.0)),
179 Anglerust-analyzer cargo pracstro 1.1.1 time/Angle#::from_degreesrust-analyzer cargo pracstro 1.1.1 time/impl#[Angle]from_degrees().(55.47885),
180 Anglerust-analyzer cargo pracstro 1.1.1 time/Angle#::from_degreesrust-analyzer cargo pracstro 1.1.1 time/impl#[Angle]from_degrees().(133.94531)
181 ),
182 (
183 Anglerust-analyzer cargo pracstro 1.1.1 time/Angle#::from_degminsecrust-analyzer cargo pracstro 1.1.1 time/impl#[Angle]from_degminsec().(220, 39, 16.2),
184 Anglerust-analyzer cargo pracstro 1.1.1 time/Angle#::from_degminsecrust-analyzer cargo pracstro 1.1.1 time/impl#[Angle]from_degminsec().(48, 6, 46.1)
185 )
186 );
187 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(
188 sirius.horizonrust-analyzer cargo pracstro 1.1.1 coord/impl#[Coord]horizon().(
189 Daterust-analyzer cargo pracstro 1.1.1 time/Date#::from_calendarrust-analyzer cargo pracstro 1.1.1 time/impl#[Date]from_calendar().(2025, 3, 7, Anglerust-analyzer cargo pracstro 1.1.1 time/Angle#::from_clockrust-analyzer cargo pracstro 1.1.1 time/impl#[Angle]from_clock().(23, 36, 52.0)),
190 Anglerust-analyzer cargo pracstro 1.1.1 time/Angle#::from_degreesrust-analyzer cargo pracstro 1.1.1 time/impl#[Angle]from_degrees().(5.0),
191 Anglerust-analyzer cargo pracstro 1.1.1 time/Angle#::from_degreesrust-analyzer cargo pracstro 1.1.1 time/impl#[Angle]from_degrees().(-rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f64][Neg]neg().1.0)
192 ),
193 (
194 Anglerust-analyzer cargo pracstro 1.1.1 time/Angle#::from_degminsecrust-analyzer cargo pracstro 1.1.1 time/impl#[Angle]from_degminsec().(249, 37, 18.2),
195 Anglerust-analyzer cargo pracstro 1.1.1 time/Angle#::from_degminsecrust-analyzer cargo pracstro 1.1.1 time/impl#[Angle]from_degminsec().(28, 34, 54.8)
196 )
197 );
198 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(
199 sirius.horizonrust-analyzer cargo pracstro 1.1.1 coord/impl#[Coord]horizon().(
200 Daterust-analyzer cargo pracstro 1.1.1 time/Date#::from_calendarrust-analyzer cargo pracstro 1.1.1 time/impl#[Date]from_calendar().(2025, 3, 11, Anglerust-analyzer cargo pracstro 1.1.1 time/Angle#::from_clockrust-analyzer cargo pracstro 1.1.1 time/impl#[Angle]from_clock().(2, 0, 0.0)),
201 Anglerust-analyzer cargo pracstro 1.1.1 time/Angle#::from_degreesrust-analyzer cargo pracstro 1.1.1 time/impl#[Angle]from_degrees().(44.8714),
202 Anglerust-analyzer cargo pracstro 1.1.1 time/Angle#::from_degreesrust-analyzer cargo pracstro 1.1.1 time/impl#[Angle]from_degrees().(-rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f64][Neg]neg().93.20801)
203 ),
204 (
205 Anglerust-analyzer cargo pracstro 1.1.1 time/Angle#::from_degminsecrust-analyzer cargo pracstro 1.1.1 time/impl#[Angle]from_degminsec().(184, 47, 2.3),
206 Anglerust-analyzer cargo pracstro 1.1.1 time/Angle#::from_degminsecrust-analyzer cargo pracstro 1.1.1 time/impl#[Angle]from_degminsec().(29, 45, 27.2)
207 )
208 );
209 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(
210 Coordrust-analyzer cargo pracstro 1.1.1 coord/Coord#::from_horizonrust-analyzer cargo pracstro 1.1.1 coord/impl#[Coord]from_horizon().(
211 Anglerust-analyzer cargo pracstro 1.1.1 time/Angle#::from_degminsecrust-analyzer cargo pracstro 1.1.1 time/impl#[Angle]from_degminsec().(184, 47, 2.3),
212 Anglerust-analyzer cargo pracstro 1.1.1 time/Angle#::from_degminsecrust-analyzer cargo pracstro 1.1.1 time/impl#[Angle]from_degminsec().(29, 45, 27.2),
213 Daterust-analyzer cargo pracstro 1.1.1 time/Date#::from_calendarrust-analyzer cargo pracstro 1.1.1 time/impl#[Date]from_calendar().(2025, 3, 11, Anglerust-analyzer cargo pracstro 1.1.1 time/Angle#::from_clockrust-analyzer cargo pracstro 1.1.1 time/impl#[Angle]from_clock().(2, 0, 0.0)),
214 Anglerust-analyzer cargo pracstro 1.1.1 time/Angle#::from_degreesrust-analyzer cargo pracstro 1.1.1 time/impl#[Angle]from_degrees().(44.8714),
215 Anglerust-analyzer cargo pracstro 1.1.1 time/Angle#::from_degreesrust-analyzer cargo pracstro 1.1.1 time/impl#[Angle]from_degrees().(-rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f64][Neg]neg().93.20801)
216 ),
217 sirius
218 );
219 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(sirius.distrust-analyzer cargo pracstro 1.1.1 coord/impl#[Coord]dist().(arcturus), Anglerust-analyzer cargo pracstro 1.1.1 time/Angle#::from_degminsecrust-analyzer cargo pracstro 1.1.1 time/impl#[Angle]from_degminsec().(115, 55, 5.17));
220 }
221
222 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
223 fn test_risesetrust-analyzer cargo pracstro 1.1.1 coord/tests/test_riseset().() {
224 let c = Coordrust-analyzer cargo pracstro 1.1.1 coord/Coord#::from_equatorialrust-analyzer cargo pracstro 1.1.1 coord/impl#[Coord]from_equatorial().(
225 Anglerust-analyzer cargo pracstro 1.1.1 time/Angle#::from_clockrust-analyzer cargo pracstro 1.1.1 time/impl#[Angle]from_clock().(23, 39, 20.0),
226 Anglerust-analyzer cargo pracstro 1.1.1 time/Angle#::from_degminsecrust-analyzer cargo pracstro 1.1.1 time/impl#[Angle]from_degminsec().(21, 42, 00.0),
227 );
228 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(
229 c.risesetrust-analyzer cargo pracstro 1.1.1 coord/impl#[Coord]riseset().(
230 Daterust-analyzer cargo pracstro 1.1.1 time/Date#::from_calendarrust-analyzer cargo pracstro 1.1.1 time/impl#[Date]from_calendar().(1980, 8, 24, Anglerust-analyzer cargo pracstro 1.1.1 time/Angle#::defaultrust-analyzer cargo pracstro 1.1.1 time/impl#[Angle][Default]default().()),
231 Anglerust-analyzer cargo pracstro 1.1.1 time/Angle#::from_degreesrust-analyzer cargo pracstro 1.1.1 time/impl#[Angle]from_degrees().(30.0),
232 Anglerust-analyzer cargo pracstro 1.1.1 time/Angle#::from_degreesrust-analyzer cargo pracstro 1.1.1 time/impl#[Angle]from_degrees().(64.0)
233 ),
234 Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#((Anglerust-analyzer cargo pracstro 1.1.1 time/Angle#::from_clockrust-analyzer cargo pracstro 1.1.1 time/impl#[Angle]from_clock().(14, 18, 9.0), Anglerust-analyzer cargo pracstro 1.1.1 time/Angle#::from_clockrust-analyzer cargo pracstro 1.1.1 time/impl#[Angle]from_clock().(4, 6, 5.0)))
235 );
236 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(
237 c.risesetrust-analyzer cargo pracstro 1.1.1 coord/impl#[Coord]riseset().(
238 Daterust-analyzer cargo pracstro 1.1.1 time/Date#::from_calendarrust-analyzer cargo pracstro 1.1.1 time/impl#[Date]from_calendar().(1980, 8, 24, Anglerust-analyzer cargo pracstro 1.1.1 time/Angle#::defaultrust-analyzer cargo pracstro 1.1.1 time/impl#[Angle][Default]default().()),
239 Anglerust-analyzer cargo pracstro 1.1.1 time/Angle#::from_degreesrust-analyzer cargo pracstro 1.1.1 time/impl#[Angle]from_degrees().(-rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f64][Neg]neg().85.0),
240 Anglerust-analyzer cargo pracstro 1.1.1 time/Angle#::from_degreesrust-analyzer cargo pracstro 1.1.1 time/impl#[Angle]from_degrees().(0.0),
241 ),
242 Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#
243 );
244 }
245
246 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
247 fn test_eclipticrust-analyzer cargo pracstro 1.1.1 coord/tests/test_ecliptic().() {
248 let star1 = Coordrust-analyzer cargo pracstro 1.1.1 coord/Coord#::from_equatorialrust-analyzer cargo pracstro 1.1.1 coord/impl#[Coord]from_equatorial().(
249 Anglerust-analyzer cargo pracstro 1.1.1 time/Angle#::from_clockrust-analyzer cargo pracstro 1.1.1 time/impl#[Angle]from_clock().(9, 34, 53.6),
250 Anglerust-analyzer cargo pracstro 1.1.1 time/Angle#::from_degminsecrust-analyzer cargo pracstro 1.1.1 time/impl#[Angle]from_degminsec().(19, 32, 14.2),
251 );
252 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(
253 star1.eclipticrust-analyzer cargo pracstro 1.1.1 coord/impl#[Coord]ecliptic().(Daterust-analyzer cargo pracstro 1.1.1 time/Date#::from_calendarrust-analyzer cargo pracstro 1.1.1 time/impl#[Date]from_calendar().(1950, 0, 1, Anglerust-analyzer cargo pracstro 1.1.1 time/Angle#::defaultrust-analyzer cargo pracstro 1.1.1 time/impl#[Angle][Default]default().())),
254 (
255 Anglerust-analyzer cargo pracstro 1.1.1 time/Angle#::from_degminsecrust-analyzer cargo pracstro 1.1.1 time/impl#[Angle]from_degminsec().(139, 41, 10.0),
256 Anglerust-analyzer cargo pracstro 1.1.1 time/Angle#::from_degminsecrust-analyzer cargo pracstro 1.1.1 time/impl#[Angle]from_degminsec().(4, 52, 31.0)
257 )
258 );
259 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(
260 Coordrust-analyzer cargo pracstro 1.1.1 coord/Coord#::from_eclipticrust-analyzer cargo pracstro 1.1.1 coord/impl#[Coord]from_ecliptic().(
261 Anglerust-analyzer cargo pracstro 1.1.1 time/Angle#::from_degminsecrust-analyzer cargo pracstro 1.1.1 time/impl#[Angle]from_degminsec().(139, 41, 10.0),
262 Anglerust-analyzer cargo pracstro 1.1.1 time/Angle#::from_degminsecrust-analyzer cargo pracstro 1.1.1 time/impl#[Angle]from_degminsec().(4, 52, 31.0),
263 Daterust-analyzer cargo pracstro 1.1.1 time/Date#::from_calendarrust-analyzer cargo pracstro 1.1.1 time/impl#[Date]from_calendar().(1950, 0, 1, Anglerust-analyzer cargo pracstro 1.1.1 time/Angle#::defaultrust-analyzer cargo pracstro 1.1.1 time/impl#[Angle][Default]default().())
264 ),
265 star1
266 );
267 }
268 }