use crate::config::parameters::PI;

pub fn degrees_to_radians(deg: f64) -> f64 {
    deg * PI / 180.0
}

pub fn radians_to_degrees(rad: f64) -> f64 {
    rad * 180.0 / PI
}

pub fn clamp_positive(x: f64) -> f64 {
    if x > 0.0 { x } else { 0.0 }
}

pub fn log10_safe(x: f64) -> f64 {
    if x > 0.0 {
        x.log10()
    } else {
        f64::NEG_INFINITY
    }
}

pub fn lerp(a: f64, b: f64, t: f64) -> f64 {
    a + (b - a) * t
}

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)
}
