rkepler 0.4.2

Astronomical almanac algorithms for the Rust
Documentation

    use crate::math::angle::*;
    use crate::math::vector::vec_p;
    use crate::math::vector::vec_p::VecP;

    pub struct PhysPrm {
        pub rad_mean: f64,
        pub rad_equ: f64,
        pub flatt_pol: f64,
        pub mag_v10: f64,
    }

    impl PhysPrm {
        pub fn vis_mag(&self, dist_sun_body: f64, dist_obs_body: f64) -> f64 {
            self.mag_v10 + 5.0 * (dist_sun_body * dist_obs_body).log10()
        }

        pub fn vis_mean_rad(&self, dist_obs_body: f64) -> f64 {
            (self.rad_mean / dist_obs_body).atan()
        }

        pub fn vis_equ_rad(&self, dist_obs_body: f64) -> f64 {
            (self.rad_equ / dist_obs_body).atan()
        }

        pub fn vis_pol_rad(&self, vis_equ_rad: f64, lat_sop: f64) -> f64 {
            let c = lat_sop.cos();
            let c2 = c * c;
            vis_equ_rad * (1.0 - self.flatt_pol * c2)
        }
    }

    pub fn elongation(obs_sun: &VecP, obs_body: &VecP) -> f64 {
        vec_p::sep_angl(&obs_sun, &obs_body)
    }

    pub fn phase_angl(body_sun: &VecP, body_obs: &VecP) -> f64 {
        vec_p::sep_angl(&body_sun, &body_obs)
    }

    pub fn phase(phase_angl: f64) -> f64 {
        (1.0 + phase_angl.cos()) / 2.0
    }

    pub fn surf_bright(vmag: f64, rad_equ: f64, rad_pol: f64, phase: f64) -> f64 {
        vmag + 2.5 * (PI * rad_equ * rad_pol * phase).log10()
    }