Debian Codegraph @

src/celobj.rs

raw symbols SCIP
1 //! Celestial object trait for generics
2
3 use crate::coord::Coord;
4 use crate::time;
5
6 /// A celestial object in pracstro is defined by the ability to query its cartesian coordinates from time
7 pub trait CelObj {
8 /// The cartesian coordinates of the object
9 fn locationcart(&self, d: time::Date) -> (f64, f64, f64);
10
11 /// The 2D Polar Coordinates of the object
12 fn location(&self, d: time::Date) -> Coord {
13 let (x, y, z) = self.locationcart(d);
14 Coord::from_cartesian(x, y, z)
15 }
16
17 /// The distance from the reference frame to the object, in AU
18 fn distance(&self, d: time::Date) -> f64 {
19 let (x, y, z) = self.locationcart(d);
20 (x * x + y * y + z * z).sqrt()
21 }
22 }