pub fn iterate(&mut self, iter_ix: usize) -> f64 {
        let n = self.pts.len();
        if n < 3 {
            return 0.0;
        }
        // Fix endpoint tangents
        let seg0 = self.get_seg(0);
        self.ths[0] += endpoint_tangent(seg0.th1) - seg0.th0;
        let seg0 = self.get_seg(n - 2);
        self.ths[n - 1] -= endpoint_tangent(seg0.th0) - seg0.th1;

        let mut abs_err = 0.0;
        let mut x = vec![0.0; n - 2];
        let (hb, mut seg0) = self.get_hyperbezier(0);
        let mut r0 = hb.compute();
        let mut ch0 = seg0.d.hypot();
        for i in 0..n - 2 {
            let (hb, seg1) = self.get_hyperbezier(i + 1);
            let r1 = hb.compute();
            let ch1 = seg1.d.hypot();
            let err = compute_err(ch0, r0, ch1, r1);
            abs_err += err.abs();

            const EPSILON: f64 = 1e-3;
            let ak0p = Self::compute_curvature(seg0.th0, seg0.th1 + EPSILON);
            let ak1p = Self::compute_curvature(seg1.th0 - EPSILON, seg1.th1);
            let errp = compute_err(ch0, ak0p, ch1, ak1p);
            let derr = (errp - err) * (1.0 / EPSILON);

            x[i] = err / derr;

            r0 = r1;
            ch0 = ch1;
            seg0 = seg1;
        }
        let scale = (0.25 * (iter_ix as f64 + 1.0)).tanh();
        for i in 0..n - 2 {
            self.ths[i + 1] += scale * x[i];
        }
        abs_err
    }
/// Perform one iteration step.
///
/// The current implementation is somewhat janky; it's mostly based
/// on the research spline, which is kinda good enough.
///
/// Returns the absolute error.
Perform one iteration step.
The current implementation is somewhat janky; it's mostly based
on the research spline, which is kinda good enough.

Returns the absolute error.
Perform one iteration step . The current implementation is somewhat janky ; it ' s mostly based on the research spline which is kinda good enough . Returns the absolute error .
pub fn iterate(&mut self, iter_ix: usize) -> f64 {
        let n = self.pts.len();
        if n < 3 {
            return 0.0;
        }
        // Fix endpoint tangents
        let seg0 = self.get_seg(0);
        self.ths[0] += endpoint_tangent(seg0.th1) - seg0.th0;
        let seg0 = self.get_seg(n - 2);
        self.ths[n - 1] -= endpoint_tangent(seg0.th0) - seg0.th1;
        let mut abs_err = 0.0;
        let mut x = vec![0.0; n - 2];
        let (hb, mut seg0) = self.get_hyperbezier(0);
        let mut r0 = hb.compute();
        let mut ch0 = seg0.d.hypot();
        for i in 0..n - 2 {
            let (hb, seg1) = self.get_hyperbezier(i + 1);
            let r1 = hb.compute();
            let ch1 = seg1.d.hypot();
            let err = compute_err(ch0, r0, ch1, r1);
            abs_err += err.abs();
            const EPSILON: f64 = 1e-3;
            let ak0p = Self::compute_curvature(seg0.th0, seg0.th1 + EPSILON);
            let ak1p = Self::compute_curvature(seg1.th0 - EPSILON, seg1.th1);
            let errp = compute_err(ch0, ak0p, ch1, ak1p);
            let derr = (errp - err) * (1.0 / EPSILON);
            x[i] = err / derr;
            r0 = r1;
            ch0 = ch1;
            seg0 = seg1;
        }
        let scale = (0.25 * (iter_ix as f64 + 1.0)).tanh();
        for i in 0..n - 2 {
            self.ths[i + 1] += scale * x[i];
        }
        abs_err
    }
pub fn iterate ( & mut self , iter_ix : usize ) -> f64 { let n = self . pts . len ( ) ; if n < 3 { return 0.0 ; } // Fix endpoint tangents let seg0 = self . get_seg ( 0 ) ; self . ths [ 0 ] += endpoint_tangent ( seg0 . th1 ) - seg0 . th0 ; let seg0 = self . get_seg ( n - 2 ) ; self . ths [ n - 1 ] -= endpoint_tangent ( seg0 . th0 ) - seg0 . th1 ; let mut abs_err = 0.0 ; let mut x = vec ! [ 0.0 n 2 ] ; let ( hb , mut seg0 ) = self . get_hyperbezier ( 0 ) ; let mut r0 = hb . compute ( ) ; let mut ch0 = seg0 . d . hypot ( ) ; for i in 0 .. n - 2 { let ( hb , seg1 ) = self . get_hyperbezier ( i + 1 ) ; let r1 = hb . compute ( ) ; let ch1 = seg1 . d . hypot ( ) ; let err = compute_err ( ch0 , r0 , ch1 , r1 ) ; abs_err += err . abs ( ) ; const EPSILON : f64 = 1e-3 ; let ak0p = Self :: compute_curvature ( seg0 . th0 , seg0 . th1 + EPSILON ) ; let ak1p = Self :: compute_curvature ( seg1 . th0 - EPSILON , seg1 . th1 ) ; let errp = compute_err ( ch0 , ak0p , ch1 , ak1p ) ; let derr = ( errp - err ) * ( 1.0 / EPSILON ) ; x [ i ] = err / derr ; r0 = r1 ; ch0 = ch1 ; seg0 = seg1 ; } let scale = ( 0.25 * ( iter_ix as f64 + 1.0 ) ) . tanh ( ) ; for i in 0 .. n - 2 { self . ths [ i + 1 ] += scale * x [ i ] ; } abs_err }
Perform one iteration step.
Perform one iteration step .
&mut self
iter_ix
usize
&mut self
iter_ix
usize