use crate::errors::RocheError;
use crate::{Vec3, Star};
use crate::{x_l1_1, x_l1_2, rpot1, rpot2};
use pyo3::prelude::*;
#[pyfunction]
pub fn ref_sphere(q: f64, star: Star, spin: f64, ffac: f64) -> Result<(f64, f64), RocheError> {
let tref: f64;
let rref: f64;
let pref: f64;
if star == Star::Primary {
tref = x_l1_1(q, spin)?;
rref = tref * 1.0_f64.min(1.001*ffac);
pref = rpot1(q, spin, &Vec3 { x: ffac*tref, y: 0.0, z: 0.0 })?;
Ok((rref, pref))
} else if star == Star::Secondary {
tref = 1.0 - x_l1_2(q, spin)?;
rref = tref * 1.0_f64.min(1.001*ffac);
pref = rpot2(q, spin, &Vec3 { x: 1.0 - ffac*tref, y: 0.0, z: 0.0 })?;
Ok((rref, pref))
} else {
let message = format!("{:?} is not and instance of Star.", star);
return Err(RocheError::ParameterError(message));
}
}