1 / 41

CSCE441: Computer Graphics 3D Transformations

CSCE441: Computer Graphics 3D Transformations. Jinxiang Chai. Review: Translation & Rotation & Scaling. Translation: Rotation: Scaling:. x’ cos( q ) -sin( q ) 0 x y’ sin( q ) cos( q ) 0 * y 1 0 0 1 1.

Download Presentation

CSCE441: Computer Graphics 3D Transformations

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. CSCE441: Computer Graphics3D Transformations Jinxiang Chai

  2. Review: Translation & Rotation & Scaling Translation: Rotation: Scaling: x’ cos(q) -sin(q) 0 x y’ sin(q) cos(q) 0 * y 1 0 0 1 1 = x’ Sx 0 0 x y’ = 0 Sy 0 * y 1 0 0 1 1 x’ 1 0 tx x y’ = 0 1 ty * y 1 0 0 1 1

  3. Review: Shearing and Reflection Shearing Reflection x 1 h 0 x y = 0 1 0 * y 1 0 0 1 1 x 1 0 0 x y = 0 -1 0 * y 1 0 0 1 1 e.g., shearing in x e.g., reflection about x axis

  4. Review : Affine Transformations Translation, rotation, scaling, and shearing are a special form of general affine transformations

  5. Review: Arbitrary Rotation Center x’ 1 0 px cos(q) -sin(q) 0 1 0 -px x y’ = 0 1 py sin(q) cos(q) 0 0 1 -py y 1 0 0 1 0 0 1 0 0 1 1 (px,py) M3 M2 M1 M= M3*M2*M1 4

  6. Review: More Trans. Composition Arbitrary scaling pivot Reflection about any arbitrary line

  7. How can we extend translation, rotation and scaling into 3D space?

  8. 3D Transformation A 3D point (x,y,z) – x,y, and z coordinates We will still use column vectors to represent points. Homogeneous coordinates of a 3D point (x,y,z,1) Transformation will be performed using 4x4 matrix

  9. Right-handed Coordinate System Left hand coordinate system Not used in this class and Not in OpenGL

  10. 3D Transformation Homogenous coordinates Very similar to 2D transformation Translation transformation

  11. 3D Transformation Homogenous coordinates Very similar to 2D transformation Scaling transformation

  12. 3D Transformation y + x z 3D rotation is done around a rotation axis Fundamental rotations – rotate about x, y, or z axes Counter-clockwise rotation is referred to as positive rotation (when you look down negative axis)

  13. 3D Transformation Keep z constant! y + x z Rotation about z – similar to 2D rotation

  14. y x z 3D Transformation z y x Rotation about y: z -> y, y -> x, x->z

  15. 3D Transformation x z y y x z Rotation about x (z -> x, y -> z, x->y)

  16. Inverse of 3D Transformations Invert the transformation matrix In general, X= AX’-->X’=A-1X T(-tx,-ty,-tz) T(tx,ty,tz)

  17. 3D Rotation about Arbitrary Axes Rotate p about the by the angle 16

  18. 3-D Rotation • General rotations in 3-D require rotating about an arbitrary axis of rotation • Deriving the rotation matrix for such a rotation directly is a good exercise in linear algebra • The general rotation matrix is a combination of coordinate-axis rotations and translations!

  19. 3D Rotation about Arbitrary Axes Rotate p about the by the angle

  20. 3-D Rotation • General rotations in 3-D require rotating about an arbitrary axis of rotation • Deriving the rotation matrix for such a rotation directly is a good exercise in linear algebra • Standard approach: express general rotation as composition of canonical rotations • Rotations about x, y, z

  21. Composing Canonical Rotations • Goal: rotate about arbitrary vector r by θ • Idea: we know how to rotate about x,y,z • Set up a transformation that superimposes rotation axis onto one coordinate axis • Rotate about the coordinate axis • Translate and rotate object back via inverse of the transformation matrix

  22. Composing Canonical Rotations Goal: rotate about arbitrary vector r by θ Idea: we know how to rotate about x,y,z So, rotate about z by - until r lies in the xz plane Then rotate about y by -βuntil r coincides with +z Then rotate about z by θ Then reverse the rotation about y(byβ ) Then reverse the rotation about z(by ) 21

  23. 3D Rotation about Arbitrary Axes Rotate p about the by the angle

  24. 3D Rotation about Arbitrary Axes Translate so that rotation axis passes through the origin

  25. 3D Rotation about Arbitrary Axes Rotation by about z-axis to place the rotation vector on xoz plane

  26. 3D Rotation about Arbitrary Axes Rotation by about y-axis to align the rotation vector with z axis

  27. 3D Rotation about Arbitrary Axes Rotation by about z-axis (rotation vector)

  28. 3D Rotation about Arbitrary Axes Rotation by about y-axis

  29. 3D Rotation about Arbitrary Axes Rotation by about z-axis

  30. 3D Rotation about Arbitrary Axes Translate the object back to original point

  31. 3D Rotation about Arbitrary Axes Final transformation matrix for rotating about an arbitrary axis

  32. 3D Rotation about Arbitrary Axes Final transformation matrix for rotating about an arbitrary axis 31

  33. 3D Rotation about Arbitrary Axes Final transformation matrix for rotating about an arbitrary axis

  34. 3D Rotation about Arbitrary Axes A 3 by 3 Rotation matrix—orthogonal matrix Final transformation matrix for rotating about an arbitrary axis

  35. Rotation Matrices • Orthonormal matrix: • orthogonal (columns/rows linearly independent) • normalized (columns/rows length of 1)

  36. Rotation Matrices • Orthonormal matrix: • orthogonal (columns/rows linearly independent) • normalized (columns/rows length of 1) • The inverse of an orthogonal matrix is just its transpose:

  37. Rotation Matrices • Orthonormal matrix: • orthogonal (columns/rows linearly independent) • normalized (columns/rows length of 1) • The inverse of an orthogonal matrix is just its transpose:

  38. Rotation Matrices • Orthonormal matrix: • orthogonal (columns/rows linearly independent) • normalized (columns/rows length of 1) • The inverse of an orthogonal matrix is just its transpose: e.g.,

  39. OpenGL Geometric Transformations Transformation in 3D glTranslate* (tx, ty, tz); glRotate* (theta, vx, vy, vz) glScale* (sx,sy,sz)

  40. OpenGL Geometric Transformations Transformation in 3D e.g., glTranslatef (25.0, -15.0, 0); glRotatef (90.0, 0.0, 0.0, 1.0) glScalef (2.0,-3.0,1.0)

  41. Next Lecture 2D coordinate transformations 3D coordinate transformations Lots of vector and matrix operations! 45

More Related