pub fn spline_ease(spline_map: &SplineMap, t: f64) -> f64 {
    spline_map
        .rectify
        .then(|| {
            // Convert t 0..1 to arc length 0..d
            let elapsed_distance = t * spline_map.length;

            // Find closest interval
            let len = spline_map.steps.len();
            let i = usize::min(len - 2, find_index(spline_map, elapsed_distance));
            let start = spline_map.steps[i];
            let end = spline_map.steps[i + 1];

            // Use chordal catmull-rom if we have a window of 4 steps.
            // This reduces jitter by an order of magnitude.
            if i > 0 && i < spline_map.steps.len() - 2 {
                let prev = spline_map.steps[i - 1];
                let next = spline_map.steps[i + 2];
                catmull_rom_value(
                    &prev.0,
                    &start.0,
                    &end.0,
                    &next.0,
                    prev.1,
                    start.1,
                    end.1,
                    next.1,
                    elapsed_distance,
                )
            } else {
                // Lerp steps[i] and steps[i+1]
                // (will only be used if easing beyond the start or end)
                linear_value(&start.0, &end.0, start.1, end.1, elapsed_distance)
            }
        })
        .unwrap_or(t)
}
// Look up linear easing by arc length using a spline map
Look up linear easing by arc length using a spline map
Look up linear easing by arc length using a spline map
pub fn spline_ease(spline_map: &SplineMap, t: f64) -> f64 {
    spline_map
        .rectify
        .then(|| {
            // Convert t 0..1 to arc length 0..d
            let elapsed_distance = t * spline_map.length;
            // Find closest interval
            let len = spline_map.steps.len();
            let i = usize::min(len - 2, find_index(spline_map, elapsed_distance));
            let start = spline_map.steps[i];
            let end = spline_map.steps[i + 1];
            // Use chordal catmull-rom if we have a window of 4 steps.
            // This reduces jitter by an order of magnitude.
            if i > 0 && i < spline_map.steps.len() - 2 {
                let prev = spline_map.steps[i - 1];
                let next = spline_map.steps[i + 2];
                catmull_rom_value(
                    &prev.0,
                    &start.0,
                    &end.0,
                    &next.0,
                    prev.1,
                    start.1,
                    end.1,
                    next.1,
                    elapsed_distance,
                )
            } else {
                // Lerp steps[i] and steps[i+1]
                // (will only be used if easing beyond the start or end)
                linear_value(&start.0, &end.0, start.1, end.1, elapsed_distance)
            }
        })
        .unwrap_or(t)
}
pub fn spline_ease ( spline_map : & SplineMap , t : f64 ) -> f64 { spline_map . rectify . then ( | | { // Convert t 0..1 to arc length 0..d let elapsed_distance = t * spline_map . length ; // Find closest interval let len = spline_map . steps . len ( ) ; let i = usize :: min ( len - 2 , find_index ( spline_map , elapsed_distance ) ) ; let start = spline_map . steps [ i ] ; let end = spline_map . steps [ i + 1 ] ; // Use chordal catmull-rom if we have a window of 4 steps. // This reduces jitter by an order of magnitude. if i > 0 && i < spline_map . steps . len ( ) - 2 { let prev = spline_map . steps [ i - 1 ] ; let next = spline_map . steps [ i + 2 ] ; catmull_rom_value ( & prev . 0 , & start . 0 , & end . 0 , & next . 0 , prev . 1 , start . 1 , end . 1 , next . 1 , elapsed_distance , ) } else { // Lerp steps[i] and steps[i+1] // (will only be used if easing beyond the start or end) linear_value ( & start . 0 , & end . 0 , start . 1 , end . 1 , elapsed_distance ) } } ) . unwrap_or ( t ) }
Look up linear easing by arc length using a spline map
Look up linear easing by arc length using a spline map
spline_map
&SplineMap
t
f64
spline_map
&SplineMap
t
f64