fn interpret_symbol(&self, symbol: LSA) -> TurtleStep {
        // use std::f64::consts::SQRT_2;
        use std::f64::consts::PI;

        let base_angle = 85.0_f64;
        let base_angle_rads = base_angle / 180.0_f64 * PI;

        let hyp = 1.0_f64; // length of the whole hypotenuse side
                           // the length of a line segment on the hypotenuse.
                           //
                           // For iteration 0, this is the hypotenuse.
                           // For iteration 1, this is H / (2*(1 + sin(base_angle/2)))
                           // For iteration 2,         H / (2*(1 + sin(base_angle/2)))^2
                           // and so forth.
        let hyp_unit = hyp
            / ((2.0_f64 * (1.0_f64 + (PI - (2.0_f64 * base_angle_rads)).sin()))
                .powf(self.iterations as f64));

        // cos(a) = A/H. A = hyp/2. H = A/cos(a)
        // let side_len = (hyp / 2.0_f64) / (base_angle_rads / 2.0_f64).cos();
        let side_unit = hyp_unit / 2.0_f64 / (base_angle_rads / 2.0_f64).cos();

        let side_angle = base_angle / 2.0_f64;
        let top_angle = 180.0_f64 - (2.0_f64 * side_angle);

        match symbol {
            LSA::F1 => TurtleStep::Forward(hyp_unit),
            LSA::F2 => TurtleStep::Forward(side_unit),
            LSA::F3 => TurtleStep::Forward(side_unit),
            LSA::Q1 => TurtleStep::TurnRad(deg2rad(180.0_f64 - side_angle)),
            LSA::Q2 => TurtleStep::TurnRad(deg2rad(180.0_f64 - top_angle)),
            LSA::Q3 => TurtleStep::TurnRad(deg2rad(180.0_f64 - side_angle)),
            LSA::L => TurtleStep::TurnRad(deg2rad(base_angle)),
            LSA::R => TurtleStep::TurnRad(deg2rad(-base_angle)),
        }
    }
// It is cleaner to read the Lyndenmayer System Alphabet matcher arms separately.
It is cleaner to read the Lyndenmayer System Alphabet matcher arms separately.
It is cleaner to read the Lyndenmayer System Alphabet matcher arms separately .
fn interpret_symbol(&self, symbol: LSA) -> TurtleStep {
        // use std::f64::consts::SQRT_2;
        use std::f64::consts::PI;
        let base_angle = 85.0_f64;
        let base_angle_rads = base_angle / 180.0_f64 * PI;
        let hyp = 1.0_f64; // length of the whole hypotenuse side
                           // the length of a line segment on the hypotenuse.
                           //
                           // For iteration 0, this is the hypotenuse.
                           // For iteration 1, this is H / (2*(1 + sin(base_angle/2)))
                           // For iteration 2,         H / (2*(1 + sin(base_angle/2)))^2
                           // and so forth.
        let hyp_unit = hyp
            / ((2.0_f64 * (1.0_f64 + (PI - (2.0_f64 * base_angle_rads)).sin()))
                .powf(self.iterations as f64));
        // cos(a) = A/H. A = hyp/2. H = A/cos(a)
        // let side_len = (hyp / 2.0_f64) / (base_angle_rads / 2.0_f64).cos();
        let side_unit = hyp_unit / 2.0_f64 / (base_angle_rads / 2.0_f64).cos();
        let side_angle = base_angle / 2.0_f64;
        let top_angle = 180.0_f64 - (2.0_f64 * side_angle);
        match symbol {
            LSA::F1 => TurtleStep::Forward(hyp_unit),
            LSA::F2 => TurtleStep::Forward(side_unit),
            LSA::F3 => TurtleStep::Forward(side_unit),
            LSA::Q1 => TurtleStep::TurnRad(deg2rad(180.0_f64 - side_angle)),
            LSA::Q2 => TurtleStep::TurnRad(deg2rad(180.0_f64 - top_angle)),
            LSA::Q3 => TurtleStep::TurnRad(deg2rad(180.0_f64 - side_angle)),
            LSA::L => TurtleStep::TurnRad(deg2rad(base_angle)),
            LSA::R => TurtleStep::TurnRad(deg2rad(-base_angle)),
        }
    }
fn interpret_symbol ( & self , symbol : LSA ) -> TurtleStep { // use std::f64::consts::SQRT_2; use std :: f64 :: consts :: PI ; let base_angle = 85.0_f64 ; let base_angle_rads = base_angle / 180.0_f64 * PI ; let hyp = 1.0_f64 ; // length of the whole hypotenuse side // the length of a line segment on the hypotenuse. // // For iteration 0, this is the hypotenuse. // For iteration 1, this is H / (2*(1 + sin(base_angle/2))) // For iteration 2,         H / (2*(1 + sin(base_angle/2)))^2 // and so forth. let hyp_unit = hyp / ( ( 2.0_f64 * ( 1.0_f64 + ( PI - ( 2.0_f64 * base_angle_rads ) ) . sin ( ) ) ) . powf ( self . iterations as f64 ) ) ; // cos(a) = A/H. A = hyp/2. H = A/cos(a) // let side_len = (hyp / 2.0_f64) / (base_angle_rads / 2.0_f64).cos(); let side_unit = hyp_unit / 2.0_f64 / ( base_angle_rads / 2.0_f64 ) . cos ( ) ; let side_angle = base_angle / 2.0_f64 ; let top_angle = 180.0_f64 - ( 2.0_f64 * side_angle ) ; match symbol { LSA :: F1 => TurtleStep :: Forward ( hyp_unit ) , LSA :: F2 => TurtleStep :: Forward ( side_unit ) , LSA :: F3 => TurtleStep :: Forward ( side_unit ) , LSA :: Q1 => TurtleStep :: TurnRad ( deg2rad ( 180.0_f64 - side_angle ) ) , LSA :: Q2 => TurtleStep :: TurnRad ( deg2rad ( 180.0_f64 - top_angle ) ) , LSA :: Q3 => TurtleStep :: TurnRad ( deg2rad ( 180.0_f64 - side_angle ) ) , LSA :: L => TurtleStep :: TurnRad ( deg2rad ( base_angle ) ) , LSA :: R => TurtleStep :: TurnRad ( deg2rad ( - base_angle ) ) , } }
It is cleaner to read the Lyndenmayer System Alphabet matcher arms separately.
It is cleaner to read the Lyndenmayer System Alphabet matcher arms separately .
&self
symbol
LSA