Hello I am having trouble getting a Hilbert curve to appear using the following L System:
- **X: ** “^ / X F ^ / X F X - F ^ / / X F X & F + / / X F X - F / X - /”
- **Initial String: ** X
- 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
- **A: ** “[&FFFA] //// [&FFFA] //// [&FFFA]”
- **Initial String: ** FFFA
- 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)