oxiproj-core 0.1.1

Foundation types for OxiProj: coordinates, errors, ellipsoids, datums, and units.
Documentation
//! Math compatibility shims: delegates to `std` or `libm` depending on the feature.
//!
//! When the `no_std` feature is active, transcendental functions are not
//! available as inherent `f64` methods; `libm` provides them instead.
//! This module presents a uniform interface so the rest of the crate is
//! feature-agnostic.

#[cfg(not(feature = "no_std"))]
mod inner {
    #[inline]
    pub fn sin(x: f64) -> f64 {
        x.sin()
    }
    #[inline]
    pub fn cos(x: f64) -> f64 {
        x.cos()
    }
    #[inline]
    pub fn tan(x: f64) -> f64 {
        x.tan()
    }
    #[inline]
    pub fn asin(x: f64) -> f64 {
        x.asin()
    }
    #[inline]
    pub fn acos(x: f64) -> f64 {
        x.acos()
    }
    #[inline]
    pub fn atan(x: f64) -> f64 {
        x.atan()
    }
    #[inline]
    pub fn atanh(x: f64) -> f64 {
        x.atanh()
    }
    #[inline]
    pub fn atan2(y: f64, x: f64) -> f64 {
        y.atan2(x)
    }
    #[inline]
    pub fn sqrt(x: f64) -> f64 {
        x.sqrt()
    }
    #[inline]
    pub fn cbrt(x: f64) -> f64 {
        x.cbrt()
    }
    #[inline]
    pub fn exp(x: f64) -> f64 {
        x.exp()
    }
    #[inline]
    pub fn ln(x: f64) -> f64 {
        x.ln()
    }
    #[inline]
    pub fn abs(x: f64) -> f64 {
        x.abs()
    }
    #[inline]
    pub fn sinh(x: f64) -> f64 {
        x.sinh()
    }
    #[inline]
    pub fn cosh(x: f64) -> f64 {
        x.cosh()
    }
    #[inline]
    pub fn tanh(x: f64) -> f64 {
        x.tanh()
    }
    #[inline]
    pub fn hypot(x: f64, y: f64) -> f64 {
        x.hypot(y)
    }
    #[inline]
    pub fn powi(x: f64, n: i32) -> f64 {
        x.powi(n)
    }
    #[inline]
    pub fn powf(x: f64, y: f64) -> f64 {
        x.powf(y)
    }
    #[inline]
    pub fn floor(x: f64) -> f64 {
        x.floor()
    }
    #[inline]
    pub fn ceil(x: f64) -> f64 {
        x.ceil()
    }
    #[inline]
    pub fn round(x: f64) -> f64 {
        x.round()
    }
    #[inline]
    pub fn signum(x: f64) -> f64 {
        x.signum()
    }
}

#[cfg(feature = "no_std")]
mod inner {
    #[inline]
    pub fn sin(x: f64) -> f64 {
        libm::sin(x)
    }
    #[inline]
    pub fn cos(x: f64) -> f64 {
        libm::cos(x)
    }
    #[inline]
    pub fn tan(x: f64) -> f64 {
        libm::tan(x)
    }
    #[inline]
    pub fn asin(x: f64) -> f64 {
        libm::asin(x)
    }
    #[inline]
    pub fn acos(x: f64) -> f64 {
        libm::acos(x)
    }
    #[inline]
    pub fn atan(x: f64) -> f64 {
        libm::atan(x)
    }
    #[inline]
    pub fn atanh(x: f64) -> f64 {
        libm::atanh(x)
    }
    #[inline]
    pub fn atan2(y: f64, x: f64) -> f64 {
        libm::atan2(y, x)
    }
    #[inline]
    pub fn sqrt(x: f64) -> f64 {
        libm::sqrt(x)
    }
    #[inline]
    pub fn cbrt(x: f64) -> f64 {
        libm::cbrt(x)
    }
    #[inline]
    pub fn exp(x: f64) -> f64 {
        libm::exp(x)
    }
    #[inline]
    pub fn ln(x: f64) -> f64 {
        libm::log(x)
    }
    #[inline]
    pub fn abs(x: f64) -> f64 {
        libm::fabs(x)
    }
    #[inline]
    pub fn sinh(x: f64) -> f64 {
        libm::sinh(x)
    }
    #[inline]
    pub fn cosh(x: f64) -> f64 {
        libm::cosh(x)
    }
    #[inline]
    pub fn tanh(x: f64) -> f64 {
        libm::tanh(x)
    }
    #[inline]
    pub fn hypot(x: f64, y: f64) -> f64 {
        libm::hypot(x, y)
    }
    #[inline]
    pub fn powi(x: f64, n: i32) -> f64 {
        libm::pow(x, n as f64)
    }
    #[inline]
    pub fn powf(x: f64, y: f64) -> f64 {
        libm::pow(x, y)
    }
    #[inline]
    pub fn floor(x: f64) -> f64 {
        libm::floor(x)
    }
    #[inline]
    pub fn ceil(x: f64) -> f64 {
        libm::ceil(x)
    }
    #[inline]
    pub fn round(x: f64) -> f64 {
        libm::round(x)
    }
    #[inline]
    pub fn signum(x: f64) -> f64 {
        if x > 0.0 {
            1.0
        } else if x < 0.0 {
            -1.0
        } else {
            0.0
        }
    }
}

pub use inner::*;