pub fn solve_for_theta(params: &ThetaParams) -> HyperBezier {
        let ThetaParams {
            th0,
            bias0,
            th1,
            bias1,
        } = *params;
        let mut dth = 0.0;
        let mut lastxy: Option<(f64, f64)> = None;
        const N: usize = 10;
        for i in 0..N {
            let params = HyperBezier {
                k0: th0 + 0.5 * dth,
                bias0,
                k1: th1 - 0.5 * dth,
                bias1,
            };
            if i == N - 1 {
                return params;
            }
            let result = params.compute();
            let th_err = util::mod_tau(th0 - th1 - (result.th0 - result.th1));
            if th_err.abs() < 1e-3 {
                return params;
            }
            // Secant method
            let nextxy = (dth, th_err);
            let delta = if let Some(lastxy) = lastxy {
                (nextxy.0 - lastxy.0) / (nextxy.1 - lastxy.1)
            } else {
                -0.5
            };
            dth -= delta * th_err;
            lastxy = Some(nextxy);
        }
        unreachable!()
    }
/// Solve for curve params, given theta params.
Solve for curve params, given theta params.
Solve for curve params given theta params .
pub fn solve_for_theta(params: &ThetaParams) -> HyperBezier {
        let ThetaParams {
            th0,
            bias0,
            th1,
            bias1,
        } = *params;
        let mut dth = 0.0;
        let mut lastxy: Option<(f64, f64)> = None;
        const N: usize = 10;
        for i in 0..N {
            let params = HyperBezier {
                k0: th0 + 0.5 * dth,
                bias0,
                k1: th1 - 0.5 * dth,
                bias1,
            };
            if i == N - 1 {
                return params;
            }
            let result = params.compute();
            let th_err = util::mod_tau(th0 - th1 - (result.th0 - result.th1));
            if th_err.abs() < 1e-3 {
                return params;
            }
            // Secant method
            let nextxy = (dth, th_err);
            let delta = if let Some(lastxy) = lastxy {
                (nextxy.0 - lastxy.0) / (nextxy.1 - lastxy.1)
            } else {
                -0.5
            };
            dth -= delta * th_err;
            lastxy = Some(nextxy);
        }
        unreachable!()
    }
pub fn solve_for_theta ( params : & ThetaParams ) -> HyperBezier { let ThetaParams { th0 , bias0 , th1 , bias1 , } = * params ; let mut dth = 0.0 ; let mut lastxy : Option < ( f64 , f64 ) > = None ; const N : usize = 10 ; for i in 0 .. N { let params = HyperBezier { k0 : th0 + 0.5 * dth , bias0 , k1 : th1 - 0.5 * dth , bias1 , } ; if i == N - 1 { return params ; } let result = params . compute ( ) ; let th_err = util :: mod_tau ( th0 - th1 - ( result . th0 - result . th1 ) ) ; if th_err . abs ( ) < 1e-3 { return params ; } // Secant method let nextxy = ( dth , th_err ) ; let delta = if let Some ( lastxy ) = lastxy { ( nextxy . 0 - lastxy . 0 ) / ( nextxy . 1 - lastxy . 1 ) } else { - 0.5 } ; dth -= delta * th_err ; lastxy = Some ( nextxy ) ; } unreachable ! ( ) }
Solve for curve params, given theta params.
Solve for curve params given theta params .
params
&ThetaParams
params
&ThetaParams