use crate::coordinates::Equatorial;
use crate::time::Time;
use crate::Result;
use nalgebra::Point3;
pub trait CelestialObject {
fn position_at(&self, time: &Time) -> Result<Equatorial>;
}
#[derive(Debug, Clone)]
pub struct CelestialBody {
pub name: String,
pub position: Point3<f64>,
}
impl CelestialBody {
pub fn new(name: &str, position: Point3<f64>) -> Self {
Self {
name: name.to_string(),
position,
}
}
}
impl CelestialObject for CelestialBody {
fn position_at(&self, _time: &Time) -> Result<Equatorial> {
Ok(Equatorial::new(0.0, 0.0))
}
}
#[cfg(test)]
mod tests {
use super::*;
use nalgebra::Point3;
#[test]
fn test_celestial_body() {
let body = CelestialBody::new("Test", Point3::new(1.0, 2.0, 3.0));
assert_eq!(body.name, "Test");
assert_eq!(body.position.x, 1.0);
assert_eq!(body.position.y, 2.0);
assert_eq!(body.position.z, 3.0);
}
}