keplerian_sim 0.7.3

A Keplerian orbit library
Documentation
//! Generated by `build.rs::sinh_approx::generate_file_contents()`
#![allow(clippy::all)]
#![allow(dead_code)]
#![allow(clippy::pedantic)]

pub struct SinhApprParams {
    pub a: f64,
    pub s: f64,
    pub p_1: f64,
    pub p_2: f64,
    pub p_3: f64,
    pub q_1: f64,
    pub q_2: f64,
}

/// Approximates the sinh(F) function given a valid SinhApprParams.
///
/// Use [`get_sinh_approx_params`] to get the approximator parameters.
///
/// # Unchecked Operation
/// This function does not check whether or not the given SinhApprParams
/// is valid. If an invalid SinhApprParams is given, nonsensical outputs may
/// be generated.
pub fn sinh_approx_lt5_inner(f: f64, args: SinhApprParams) -> f64 {
    let f_min_a = f - args.a;
    let f_min_a_sq = f_min_a * f_min_a;
    let f_min_a_cu = f_min_a * f_min_a_sq;

    let numerator = args.s + args.p_1 * f_min_a + args.p_2 * f_min_a_sq + args.p_3 * f_min_a_cu;

    let denominator = 1.0 + args.q_1 * f_min_a + args.q_2 * f_min_a_sq;

    return numerator / denominator;
}

/// Approximates the sinh(F) function for F in the interval [0, 5).
///
/// # Reduced Precision
/// This function has a reduced precision beyond the interval [0, 5).
pub fn sinh_approx_lt5(f: f64) -> f64 {
    sinh_approx_lt5_inner(f, get_sinh_approx_params(f))
}

/// Returns the parameters for the sinh approximation for the given point.
///
/// # Reduced Precision
/// This function has a reduced precision beyond the interval [0, 5).
pub fn get_sinh_approx_params(f: f64) -> SinhApprParams {
    if f < 1.44999999999999990008e-1 {
        SinhApprParams {
            a: 0.00000000000000000000e0,
            s: 0.00000000000000000000e0,
            p_1: 1.00000000000000000000e0,
            p_2: 0.00000000000000000000e0,
            p_3: 1.16666666666666668517e-1,
            q_1: -0.00000000000000000000e0,
            q_2: -5.00000000000000027756e-2,
        }
    } else if f < 3.75000000000000000000e-1 {
        SinhApprParams {
            a: 2.50000000000000000000e-1,
            s: 2.52612316808168313464e-1,
            p_1: 1.02493469681515314562e0,
            p_2: 8.76209699763339788792e-2,
            p_3: 1.18711927553178470118e-1,
            q_1: -2.56456341728572914662e-2,
            q_2: -4.84297263954722376211e-2,
        }
    } else if f < 6.25000000000000000000e-1 {
        SinhApprParams {
            a: 5.00000000000000000000e-1,
            s: 5.21095305493747384951e-1,
            p_1: 1.09895285061477632205e0,
            p_2: 1.75758187820380273880e-1,
            p_3: 1.24388083959509995746e-1,
            q_1: -5.50247033302977556213e-2,
            q_2: -4.36430351294818594243e-2,
        }
    } else if f < 8.75000000000000000000e-1 {
        SinhApprParams {
            a: 7.50000000000000000000e-1,
            s: 8.22316731935829992040e-1,
            p_1: 1.21979596921804112064e0,
            p_2: 2.64028556197162755925e-1,
            p_3: 1.32324554347597628245e-1,
            q_1: -9.10686996268581239189e-2,
            q_2: -3.55394527091821288423e-2,
        }
    } else if f < 1.12500000000000000000e0 {
        SinhApprParams {
            a: 1.00000000000000000000e0,
            s: 1.17520119364380137839e0,
            p_1: 1.38466349382188602668e0,
            p_2: 3.50995633383449634479e-1,
            p_3: 1.40421788813438946919e-1,
            q_1: -1.34800017095092788955e-1,
            q_2: -2.43342736894100325484e-2,
        }
    } else if f < 1.37500000000000000000e0 {
        SinhApprParams {
            a: 1.25000000000000000000e0,
            s: 1.60191908030082563741e0,
            p_1: 1.59321448468126991571e0,
            p_2: 4.35461029104106445153e-1,
            p_3: 1.46513770882181981747e-1,
            q_1: -1.84284834427659333089e-1,
            q_2: -1.09185474656843892888e-2,
        }
    } else if f < 1.62500000000000000000e0 {
        SinhApprParams {
            a: 1.50000000000000000000e0,
            s: 2.12927945509481730824e0,
            p_1: 1.85249684987631479949e0,
            p_2: 5.19000226009858844911e-1,
            p_3: 1.49469597103312479280e-1,
            q_1: -2.34780251211633872455e-1,
            q_2: 3.12773359362836060604e-3,
        }
    } else if f < 1.87500000000000000000e0 {
        SinhApprParams {
            a: 1.75000000000000000000e0,
            s: 2.79041436627764216638e0,
            p_1: 2.18090017207745789918e0,
            p_2: 6.07960882007475555966e-1,
            p_3: 1.49999935055619509905e-1,
            q_1: -2.80706746322955669193e-1,
            q_2: 1.60626161198984714062e-2,
        }
    } else if f < 2.25000000000000000000e0 {
        SinhApprParams {
            a: 2.00000000000000000000e0,
            s: 3.62686040784701901885e0,
            p_1: 2.60822520605437935259e0,
            p_2: 7.13171455665623454934e-1,
            p_3: 1.50430209369110695627e-1,
            q_1: -3.18173393862233977458e-1,
            q_2: 2.66819817323797926767e-2,
        }
    } else if f < 2.75000000000000000000e0 {
        SinhApprParams {
            a: 2.50000000000000000000e0,
            s: 6.05020448103978747412e0,
            p_1: 3.92101066321057833974e0,
            p_2: 1.02673191960792209443e0,
            p_3: 1.62614068514153331524e-1,
            q_1: -3.65488277856201804195e-1,
            q_2: 4.01489901849178681958e-2,
        }
    } else if f < 3.25000000000000000000e0 {
        SinhApprParams {
            a: 3.00000000000000000000e0,
            s: 1.00178749274099025968e1,
            p_1: 6.19495323415375764853e0,
            p_2: 1.57947759314435587363e0,
            p_3: 2.06383375768070698175e-1,
            q_1: -3.86579867455511150265e-1,
            q_2: 4.61670336977981349280e-2,
        }
    } else if f < 3.75000000000000000000e0 {
        SinhApprParams {
            a: 3.50000000000000000000e0,
            s: 1.65426272876349962360e1,
            p_1: 1.00391952745991286378e1,
            p_2: 2.52905732330857047074e0,
            p_3: 3.00088862508807174834e-1,
            q_1: -3.94957178376486306437e-1,
            q_2: 4.85593814895730682690e-2,
        }
    } else if f < 4.25000000000000000000e0 {
        SinhApprParams {
            a: 4.00000000000000000000e0,
            s: 2.72899171971277496596e1,
            p_1: 1.64432953350880772803e1,
            p_2: 4.12264582673895496612e0,
            p_3: 4.69726122303154414173e-1,
            q_1: -3.98130101401404590256e-1,
            q_2: 4.94657688596273695247e-2,
        }
    } else if f < 4.75000000000000000000e0 {
        SinhApprParams {
            a: 4.50000000000000000000e0,
            s: 4.50030111519917852547e1,
            p_1: 2.70439639439689756273e1,
            p_2: 6.76819322072186757566e0,
            p_3: 7.59108299521573215429e-1,
            q_1: -3.99310084915633800584e-1,
            q_2: 4.98028848796008491440e-2,
        }
    } else if f < 1.79769313486231570815e308 {
        SinhApprParams {
            a: 5.00000000000000000000e0,
            s: 7.42032105777887522891e1,
            p_1: 4.45475178277720544884e1,
            p_2: 1.11412549648523508949e1,
            p_3: 1.24221965363796948978e0,
            q_1: -3.99745920237777829787e-1,
            q_2: 4.99274062530438364482e-2,
        }
    } else {
        SinhApprParams {
            a: 0.0,
            s: 0.0,
            p_1: 0.0,
            p_2: 0.0,
            p_3: 0.0,
            q_1: 0.0,
            q_2: 0.0,
        }
    }
}
pub const SINH_5: f64 = 74.20321057778875;