Presentation is loading. Please wait.

Presentation is loading. Please wait.

3-D Transformational Geometry CS418 Computer Graphics John C. Hart.

Similar presentations


Presentation on theme: "3-D Transformational Geometry CS418 Computer Graphics John C. Hart."— Presentation transcript:

1 3-D Transformational Geometry CS418 Computer Graphics John C. Hart

2 Graphics Pipeline Homogeneous Divide Model Coords Model Xform World Coords Viewing Xform Still Clip Coords. Clipping Window Coordinates Window Coordinates Window to Viewport Window to Viewport Coordinates Viewport Coordinates Clip Coords. Viewing Coords Perspective Distortion

3 3-D Affine Transformations General Translation

4 3-D Coordinates Points represented by 4-vectors Need to decide orientation of coordinate axes y z x x z y Right Handed Coord. Sys. Left Handed Coord. Sys. x y +z (rhc) +z (lhc)

5 Scale Uniform Scale a = b = c = ¼ z y x Squash a = b = 1, c = ¼ Stretch a = b = 1, c = 4 Project a = b = 1, c = 0 Invert a = b = 1, c = -1

6 3-D Rotations About x-axis –rotates y  z About y-axis –rotates z  x About z-axis –rotates x  y Rotations do not commute!

7 Arbitrary Axis Rotation Rotations about x, y and z axes Rotation x rotation = rotation Can rotate about any axis direction Can do simply with vector algebra –Ensure ||v|| = 1 –Let o = (p  v)v –Let a = p – o –Let b = v  a, (note that ||b||=||a||) –Then p’ = o + a cos  + b sin  Simple solution to rotate a single point Difficult to generate a rotation matrix to rotate all vertices in a meshed model x y z v  p p’ a b a b  p b ||a||cos  ||a||sin  o

8 Arbitrary Rotation Find a rotation matrix that rotates by an angle  about an arbitrary unit direction vector v x z v v = (x v,y v,z v ), x v 2 +y v 2 +z v 2 =1 Rotate by  about v [ ]=[ ][ ][ ] Rotate z to v Rotate v to z Rotate by  about z y  z v x z  v z

9 Rotate v to z 1.Project v onto the yz plane and let d = sqrt(y v 2 + z v 2 ) x y z v v yz v = (x v,y v,z v ), x v 2 +y v 2 +z v 2 =1 zvzv yvyv d

10 Rotate v to z 1.Project v onto the yz plane and let d = sqrt(y v 2 + z v 2 ) 2.Then cos  x = z v /d and sin  x = y v /d x y z v v yz v = (x v,y v,z v ), x v 2 +y v 2 +z v 2 =1 zvzv yvyv d xx

11 Rotate v to z 1.Project v onto the yz plane and let d = sqrt(y v 2 + z v 2 ) 2.Then cos  x = z v /d and sin  x = y v /d 3.Rotate v by  x about x into the xz plane x y z v v yz v = (x v,y v,z v ), x v 2 +y v 2 +z v 2 =1 zvzv yvyv d xx

12 Rotate v to z 1.Project v onto the yz plane and let d = sqrt(y v 2 + z v 2 ) 2.Then cos  x = z v /d and sin  x = y v /d 3.Rotate v by  x about x into the xz plane x y z v v xz v = (x v,y v,z v ), x v 2 +y v 2 +z v 2 =1 xx

13 Rotate v to z 1.Project v onto the yz plane and let d = sqrt(y v 2 + z v 2 ) 2.Then cos  x = z v /d and sin  x = y v /d 3.Rotate v by  x about x into the xz plane 4.Then cos  y = d and sin  y = x v x y z v v xz v = (x v,y v,z v ), x v 2 +y v 2 +z v 2 =1 yy 1 d xvxv

14 Rotate v to z 1.Project v onto the yz plane and let d = sqrt(y v 2 + z v 2 ) 2.Then cos  x = z v /d and sin  x = y v /d 3.Rotate v by  x about x into the xz plane 4.Then cos  y = d and sin  y = x v 5.Rotate v xz by  y about y into the z axis x y z v v xz v = (x v,y v,z v ), x v 2 +y v 2 +z v 2 =1 yy xx

15 Rotate  about v Let R v  be the rotation matrix for rotation by  about arbitrary axis direction v Recall (R x R y ) is the matrix (product) that rotates direction v to z axis Then R v  = (R y R x ) -1 R z (  ) (R y R x ) = R x -1 R y -1 R z (  ) R y R x = R x T R y T R z (  ) R y R x (since the inverse of a rotation matrix is the transpose of the rotation matrix)

16 Easier Way Find an orthonormal vector system x y z u v

17 Easier Way Find an orthonormal vector system –Let r = u  v/||u  v|| x y z u v r

18 Easier Way Find an orthonormal vector system –Let r = u  v/||u  v|| –Let u’ = v  r x y z u v r u’

19 Easier Way Find an orthonormal vector system –Let r = u  v/||u  v|| –Let u’ = v  r Find a rotation from  x y z u v r u’

20 Graphics Pipeline Homogeneous Divide Model Coords Model Xform World Coords Viewing Xform Still Clip Coords. Clipping Window Coordinates Window Coordinates Window to Viewport Window to Viewport Coordinates Viewport Coordinates Clip Coords. Viewing Coords Perspective Distortion Screen Vertices Model Vertices

21 Graphics Pipeline Homogeneous Divide Model Coords Model Xform World Coords Viewing Xform Still Clip Coords. Clipping Window Coordinates Window Coordinates Window to Viewport Window to Viewport Coordinates Viewport Coordinates Clip Coords. Viewing Coords Perspective Distortion

22 Graphics Pipeline Homogeneous Divide Model Coords Model Xform World Coords Viewing Xform Still Clip Coords. Clipping Window Coordinates Window Coordinates Window to Viewport Window to Viewport Coordinates Viewport Coordinates Clip Coords. Viewing Coords Perspective Distortion M

23 Transformation Order M x y z glutSolidTeapot(1);glRotate3f(-90, 0,0,1); glTranslate3f(0,1,0); glutSolidTeapot(1); glTranslate3f(0,1,0); glRotate3f(-90, 0,0,1); glutSolidTeapot(1); M RT M TR


Download ppt "3-D Transformational Geometry CS418 Computer Graphics John C. Hart."

Similar presentations


Ads by Google