130 likes | 298 Views
Transformations in 3D. Lecture 17 Mon, Oct 6, 2003. 3D Affine Transformations. In 3-dimensional scenes we have the same three kinds of transformation. Translations. Rotations. Scalings. Points have three coordinates (x, y, z), with a fourth coordinate w = 1 added: (x, y, z, 1).
E N D
Transformations in 3D Lecture 17 Mon, Oct 6, 2003
3D Affine Transformations • In 3-dimensional scenes we have the same three kinds of transformation. • Translations. • Rotations. • Scalings. • Points have three coordinates (x, y, z), with a fourth coordinate w = 1 added: (x, y, z, 1)
3D Translations • The translation T(dx, dy, dz). =
3D Scalings • The scaling S(sx, sy, sz). =
3D Rotations • Rotations in space are a little more complicated. • A rotation in space is about an axis, not a point. • Any line may be the axis of rotation. • Generally we rotate about the x, y, and z axes.
3D Rotations about the z-axis • The rotation Rz(). =
Example: Rotation about the z-axis • Rotate 90 about the z-axis. • What is the image of (3, 4, 5)? Rz(90) = (3, 4, 5) (-4, 3, 5)
3D Rotations about the x-axis • The rotation Rx(). =
Example: Rotation about the x-axis • Rotate 90 about the x-axis. • What is the image of (3, 4, 5)? Rx(90) = (3, 4, 5) (3, -5, 4)
3D Rotations about the y-axis • The rotation Ry(). =
Example: Rotation about the y-axis • Rotate 90 about the z-axis. • What is the image of (3, 4, 5)? Ry(90) = (3, 4, 5) (5, 4, -3)
Direction of Rotation • For each axis (x, y, z), the positive direction of rotation is determined by the right-hand rule. • Point the thumb of your right hand in the positive direction of the axis. • Curl your fingers. • The direction of curl is the positive direction of rotation.
3D Transformations in OpenGL • OpenGL uses the functions • glTranslatef(dx, dy, dz) • glRotatef(angle, vx, vy, vz) • v = (vx, vy, vz) is a vector indicating the axis of rotation. • glScalef(sx, sy, sz)