// elide direction check hopefully since intervals should be constant
elide direction check hopefully since intervals should be constant
elide direction check hopefully since intervals should be constant
pub(crate) fn switch(
    interpolate: impl FnOnce(f64) -> (f64, f64, f64),
    interval: (f64, f64),
    x: f64,
) -> (f64, f64, f64) {
    match IntervalSide::classify(interval, x) {
        IntervalSide::Left => (0.0, 0.0, 0.0),
        IntervalSide::Inside => {
            let width = interval.1 - interval.0;
            let alpha = (x - interval.0) / width;
            let (value, d_alpha, dd_alpha_alpha) = interpolate(alpha);
            (value, d_alpha / width, dd_alpha_alpha / (width * width))
        },
        IntervalSide::Right => (1.0, 0.0, 0.0),
    }
}
pub ( crate ) fn switch ( interpolate : impl FnOnce ( f64 ) -> ( f64 , f64 , f64 ) , interval : ( f64 , f64 ) , x : f64 , ) -> ( f64 , f64 , f64 ) { match IntervalSide :: classify ( interval , x ) { IntervalSide :: Left => ( 0.0 , 0.0 , 0.0 ) , IntervalSide :: Inside => { let width = interval . 1 - interval . 0 ; let alpha = ( x - interval . 0 ) / width ; let ( value , d_alpha , dd_alpha_alpha ) = interpolate ( alpha ) ; ( value , d_alpha / width , dd_alpha_alpha / ( width * width ) ) } , IntervalSide :: Right => ( 1.0 , 0.0 , 0.0 ) , } }
elide direction check hopefully since intervals should be constant
elide direction check hopefully since intervals should be constant
interpolate
impl FnOnce(f64) -> (f64, f64, f64)
interval
(f64, f64)
x
f64