use crate::constants::physical::{KPC, LIGHT_YEAR, MPC, PARSEC, SOLAR_MASS};
pub fn m_to_kpc(m: f64) -> f64 {
m / KPC
}
pub fn kpc_to_m(kpc: f64) -> f64 {
kpc * KPC
}
pub fn m_to_mpc(m: f64) -> f64 {
m / MPC
}
pub fn mpc_to_m(mpc: f64) -> f64 {
mpc * MPC
}
pub fn m_to_pc(m: f64) -> f64 {
m / PARSEC
}
pub fn pc_to_m(pc: f64) -> f64 {
pc * PARSEC
}
pub fn m_to_ly(m: f64) -> f64 {
m / LIGHT_YEAR
}
pub fn ly_to_m(ly: f64) -> f64 {
ly * LIGHT_YEAR
}
pub fn kg_to_solar_masses(kg: f64) -> f64 {
kg / SOLAR_MASS
}
pub fn solar_masses_to_kg(m_sun: f64) -> f64 {
m_sun * SOLAR_MASS
}
pub fn cartesian_to_spherical(x: f64, y: f64, z: f64) -> (f64, f64, f64) {
let r = (x * x + y * y + z * z).sqrt();
let theta = (z / r).acos();
let phi = y.atan2(x);
(r, theta, phi)
}
pub fn spherical_to_cartesian(r: f64, theta: f64, phi: f64) -> (f64, f64, f64) {
let x = r * theta.sin() * phi.cos();
let y = r * theta.sin() * phi.sin();
let z = r * theta.cos();
(x, y, z)
}
pub fn redshift_to_scale_factor(z: f64) -> f64 {
1.0 / (1.0 + z)
}
pub fn scale_factor_to_redshift(a: f64) -> f64 {
1.0 / a - 1.0
}
pub fn log10_solar_mass(mass_kg: f64) -> f64 {
(mass_kg / SOLAR_MASS).log10()
}