fn adjust_tensions(&mut self, iter_ix: usize) {
        const MIN_BIAS: f64 = -0.9;
        let scale = (0.25 * (iter_ix as f64 + 1.0)).tanh();
        for i in 1..self.elements.len() {
            if self.elements[i].is_auto_p1()
                && self.prev_el(i).map(Element::is_given_p2).unwrap_or(false)
            {
                let prev_seg = &self.segments[self.prev_ix(i) - 1];
                let seg = &self.segments[i - 1];
                let this_ch = seg.chord().hypot();
                let bias = hyperbezier::compute_k_inv(prev_seg.k1 * this_ch / (seg.hb.k0 * seg.ch));
                let bias = bias.max(MIN_BIAS);
                let bias = seg.hb.bias0 + scale * (bias - seg.hb.bias0);
                self.segments[i - 1].hb.bias0 = bias;
            }
            if self.elements[i].is_auto_p2()
                && self.next_el(i).map(Element::is_given_p1).unwrap_or(false)
            {
                let next_seg = &self.segments[self.next_ix(i) - 1];
                let seg = &self.segments[i - 1];
                let this_ch = seg.chord().hypot();
                let bias = hyperbezier::compute_k_inv(next_seg.k0 * this_ch / (seg.hb.k1 * seg.ch));
                let bias = bias.max(MIN_BIAS);
                let bias = seg.hb.bias1 + scale * (bias - seg.hb.bias1);
                self.segments[i - 1].hb.bias1 = bias;
            }
        }
    }
/// Iterate towards G2 continuity by adjusting bias values.
Iterate towards G2 continuity by adjusting bias values.
Iterate towards G2 continuity by adjusting bias values .
fn adjust_tensions(&mut self, iter_ix: usize) {
        const MIN_BIAS: f64 = -0.9;
        let scale = (0.25 * (iter_ix as f64 + 1.0)).tanh();
        for i in 1..self.elements.len() {
            if self.elements[i].is_auto_p1()
                && self.prev_el(i).map(Element::is_given_p2).unwrap_or(false)
            {
                let prev_seg = &self.segments[self.prev_ix(i) - 1];
                let seg = &self.segments[i - 1];
                let this_ch = seg.chord().hypot();
                let bias = hyperbezier::compute_k_inv(prev_seg.k1 * this_ch / (seg.hb.k0 * seg.ch));
                let bias = bias.max(MIN_BIAS);
                let bias = seg.hb.bias0 + scale * (bias - seg.hb.bias0);
                self.segments[i - 1].hb.bias0 = bias;
            }
            if self.elements[i].is_auto_p2()
                && self.next_el(i).map(Element::is_given_p1).unwrap_or(false)
            {
                let next_seg = &self.segments[self.next_ix(i) - 1];
                let seg = &self.segments[i - 1];
                let this_ch = seg.chord().hypot();
                let bias = hyperbezier::compute_k_inv(next_seg.k0 * this_ch / (seg.hb.k1 * seg.ch));
                let bias = bias.max(MIN_BIAS);
                let bias = seg.hb.bias1 + scale * (bias - seg.hb.bias1);
                self.segments[i - 1].hb.bias1 = bias;
            }
        }
    }
fn adjust_tensions ( & mut self , iter_ix : usize ) { const MIN_BIAS : f64 = - 0.9 ; let scale = ( 0.25 * ( iter_ix as f64 + 1.0 ) ) . tanh ( ) ; for i in 1 .. self . elements . len ( ) { if self . elements [ i ] . is_auto_p1 ( ) && self . prev_el ( i ) . map ( Element :: is_given_p2 ) . unwrap_or ( false ) { let prev_seg = & self . segments [ self . prev_ix ( i ) - 1 ] ; let seg = & self . segments [ i - 1 ] ; let this_ch = seg . chord ( ) . hypot ( ) ; let bias = hyperbezier :: compute_k_inv ( prev_seg . k1 * this_ch / ( seg . hb . k0 * seg . ch ) ) ; let bias = bias . max ( MIN_BIAS ) ; let bias = seg . hb . bias0 + scale * ( bias - seg . hb . bias0 ) ; self . segments [ i - 1 ] . hb . bias0 = bias ; } if self . elements [ i ] . is_auto_p2 ( ) && self . next_el ( i ) . map ( Element :: is_given_p1 ) . unwrap_or ( false ) { let next_seg = & self . segments [ self . next_ix ( i ) - 1 ] ; let seg = & self . segments [ i - 1 ] ; let this_ch = seg . chord ( ) . hypot ( ) ; let bias = hyperbezier :: compute_k_inv ( next_seg . k0 * this_ch / ( seg . hb . k1 * seg . ch ) ) ; let bias = bias . max ( MIN_BIAS ) ; let bias = seg . hb . bias1 + scale * ( bias - seg . hb . bias1 ) ; self . segments [ i - 1 ] . hb . bias1 = bias ; } } }
Iterate towards G2 continuity by adjusting bias values.
Iterate towards G2 continuity by adjusting bias values .
&mut self
iter_ix
usize
&mut self
iter_ix
usize