Help with L System Rotations

Hello I am having trouble getting a Hilbert curve to appear using the following L System:

  1. **X: ** “^ / X F ^ / X F X - F ^ / / X F X & F + / / X F X - F / X - /”
  2. **Initial String: ** X
  3. Angle: 90

The way I am calculating the angles is as follows

if (character == 'F')
            {

                Vector3 old_pos = turtle.transform.position;
                GameObject new_point = Instantiate(point);

                turtle.transform.position += line_length * turtle.transform.up;

                new_point.transform.rotation = turtle.transform.rotation;
                Vector3 pos = turtle.transform.position;
                pos[0] += line_length;
                new_point.transform.position = pos;
                new_point.transform.localScale = new Vector3(starting_width, line_length, starting_width);
                //new_point.transform.parent = turtle.transform;


                Debug.DrawLine(old_pos,turtle.transform.position, colors[i%7], 5000f);

            }
            else if (character == 'f')
            {
                turtle.transform.position += line_length * turtle.transform.up;
            }
            else if (character == 'w')
            {
                starting_width *= width_ratio;
            }
            //Pitch down(&) and up(^) by delta
            else if (character == '&')
            {
                turtle.transform.Rotate(Vector3.right * delta);
            }
            else if (character == '^')
            {
                turtle.transform.Rotate(Vector3.left * delta);
            }
            //roll right(/) and left(*) by delta
            else if (character == '/')
            {
                turtle.transform.Rotate(Vector3.down * delta);
            }
            else if (character == '*')
            {
                turtle.transform.Rotate(Vector3.up * delta);
            }

This system works with the following L System and produces the desired result

  1. **A: ** “[&FFFA] //// [&FFFA] //// [&FFFA]”
  2. **Initial String: ** FFFA
  3. Angle: 90

However when attempting to make a Hilbert curve and other L Systems the results are not as expected

What would be the correct way to go about coding these rotations in Unity described on page 3 in the following PDF: https://www.bioquest.org/products/files/13157_Real-time%203D%20Plant%20Structure%20Modeling%20by%20L-System.pdf

(I have tried writing out the rotation matrices but it didn’t solve my problem. Let me know if any other information is required)

It seems that your used L system rule is faulty. It looks very similar to the one mentioned over here but you don’t have the proper counter rotations at some places. To quote from the SO answer:

lsystem Hilbert3D {

    set iterations = 3;
    set symbols axiom = X;

    interpret F as DrawForward(10);
    interpret + as Yaw(90);
    interpret - as Yaw(-90);
    interpret ^ as Pitch(90);
    interpret & as Pitch(-90);
    interpret > as Roll(90);
    interpret < as Roll(-90);

    rewrite X to ^ < X F ^ < X F X - F ^ > > X F X & F + > > X F X - F > X - >;

}

If you compare it to your rule, you always use a “/” where in this rule there is either a < or >. So you’re rotating in the wrong direction.

I haven’t tried this 3d hilbert curve construction rule.