Presentation is loading. Please wait.

Presentation is loading. Please wait.

Jinxiang Chai CSCE441: Computer Graphics 3D Transformations 0.

Similar presentations


Presentation on theme: "Jinxiang Chai CSCE441: Computer Graphics 3D Transformations 0."— Presentation transcript:

1 Jinxiang Chai CSCE441: Computer Graphics 3D Transformations 0

2 Review: Translation & Rotation & Scaling Translation: Rotation: Scaling: x’ 1 0 tx x y’ = 0 1 ty * y 1 0 0 1 1 x’ cos(  ) -sin(  ) 0 x y’ sin(  ) cos(  ) 0 * y 1 0 0 1 1 = x’ Sx 0 0 x y’ = 0 Sy 0 * 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., reflection about x axis e.g., shearing in x

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

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

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 7

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

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

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

12 3D Transformation 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) x y z + 11

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

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

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

16 Inverse of 3D Transformations Invert the transformation matrix In general, X= AX’-->X’=A -1 X T(t x,t y,t z ) T(-t x,-t y,-t z )

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! 17

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

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 19

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 20

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 22

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

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

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

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

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

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

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

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

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 Final transformation matrix for rotating about an arbitrary axis A 3 by 3 Rotation matrix—orthogonal matrix

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

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: 35

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: 36

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: 37

39 Why? Rotation Matrices 38 is a 3-by-3 identity matrix

40 Why? Rotation Matrices 39 is a 3-by-3 identity matrix

41 Why? Rotation Matrices 40 is a 3-by-3 identity matrix

42 Why? Rotation Matrices 41 is a 3-by-3 identity matrix

43 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., 42

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

45 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)

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


Download ppt "Jinxiang Chai CSCE441: Computer Graphics 3D Transformations 0."

Similar presentations


Ads by Google