next up previous contents index
Next: Lighting the scene Up: Turtle and 3D Previous: 3D Viewer   Contents   Index

Drawing a cube

All faces are 400 steps square. Here is the program:
to square
# we record the vertice square
polystart repeat 4[forward 400 right 90] polyend
end

to simpleCube
# yellow cube 
clearscreen perspective setpencolor yellow
# lateral faces
repeat 4[square penup right 90 forward 400 left 90 rightroll 90 pendown]
# bottom face 
downpitch 90 square uppitch 90
# upper face
forward 400 downpitch 90 square
# visualization
view3d
end
We launch with the command: simpleCube:
\includegraphics[scale=0.4, clip]{images/3dCube1.eps}
When we replace in the procedure square, polystart with linestart and polyend with lineend
\includegraphics[scale=0.4, clip]{images/3dCube2.eps}
If we had used pointstart and pointend instead of linestart and lineend, we would see on screen only the eight cube vertices. These primitives are very useful to display the point set in 3D Space.

Loïc 2008-06-08