Datasheet

22
Part 1: Getting Started
3D Rotation
To rotate x, y, z points in 3D space you use the following equations:
xnew = xold*cos(angleZ) - yold*sin(angleZ)
ynew = xold*sin(angleZ) + yold*cos(angleZ)
xnew = xold*cos(angleY) - zold*sin(angleY)
znew = xold*sin(angleY) + zold*cos(angleY)
ynew = yold*cos(angleX) - zold*sin(angleX)
znew = yold*sin(angleX) + zold*cos(angleX)
There are actually two ways to rotate elements in Papervision3D; using the preceding matrix equations
or using quaternions. Most 3D engines start with the preceding matrix equations.
Flash 10 Rotation
In Flash 10, rotation around the x, y, and z - axis is clockwise as angle increases. Rotation around the x, y,
and z - axis are accomplished using the
rotationX , rotationY , and rotationZ commands respectively.
Just as in Papervision3D, the rotational values are given in degrees as opposed to radians, which had
been the practice in Flash previously. But when using sine and cosine functions you still use radians
(see Figure 1.9).
X
Y
Y
Z
Z
X
rotationZ
rotationY
rotationX
Figure 1-9
c01.indd 22c01.indd 22 12/14/09 3:03:30 PM12/14/09 3:03:30 PM