next up previous contents index
Next: Primitives available in 2D Up: Turtle and 3D Previous: The perspective projection   Contents   Index

Understanding orientation in a 3D World

In a 2D plane, the turtle's orientation was only defined by its heading. In a 3D world, the turtle's orientation is given by 3 angles: In fact, to move itself in the 3D World, the turtle is very similar to an aircraft. Here is a little illustration which represents these 3 values:
\includegraphics[scale=0.3, clip]{images/plane-roll.eps} Roll
\includegraphics[scale=0.35, clip]{images/plane-pitch.eps} Pitch
\includegraphics[scale=0.3, clip]{images/plane-heading.eps} Heading


It seems quite complex at first, but you will see that a lot of things stay very similar to moving in a 2D plane. Here are the basic primitives for moving in the 3D world:


In the 2D plane, when we want to draw a square of side 200 steps, we write:
repeat 4[fd 200 rt 90]
These instructions are still available in the 3D world, where the square is drawn in perspective mode. If the turtle goes down $ 90$ degrees, we can draw another square and we obtain:
cs
repeat 4[fd 200 rt 90]
down 90
repeat 4[fd 200 rt 90]
\includegraphics[scale=0.4, clip]{images/perspective1.eps}

You just have to try some examples to understand these orientations and become an expert!
You must understand that the 3 rotation primitives are linked together, for example try this:

cs
leftroll 90 up 90 rightroll 90
The turtles movement is equivalent to left 90 (You can try with your hand simulating the turtle if you don't understand)

next up previous contents index
Next: Primitives available in 2D Up: Turtle and 3D Previous: The perspective projection   Contents   Index
Loïc 2008-06-08