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

3 d transformational geometry
SMART_READER_LITE
LIVE PREVIEW

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

3-D Transformational Geometry CS418 Computer Graphics John C. Hart Graphics Pipeline Model Model World Viewing Viewing Perspective Coords Xform Coords Xform Coords Distortion Still Homogeneous Clip Clip Clipping Divide Coords.


slide-1
SLIDE 1

3-D Transformational Geometry

CS418 Computer Graphics John C. Hart

slide-2
SLIDE 2

Graphics Pipeline

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

slide-3
SLIDE 3

3-D Affine Transformations

  • General
  • Translation
slide-4
SLIDE 4

3-D Coordinates

  • Points represented

by 4-vectors

  • Need to decide
  • rientation of

coordinate axes

1 x y z            

y z x x z y

Right Handed Coord. Sys. Left Handed Coord. Sys.

x y +z (rhc) +z (lhc)

slide-5
SLIDE 5

Scale

1 1 1 a x ax b y by c z cz                                     

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

slide-6
SLIDE 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!

1 cos sin sin cos 1                  cos sin 1 sin cos 1                  cos sin sin cos 1 1                 

slide-7
SLIDE 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 p’

||a||cos ||a||sin

slide-8
SLIDE 8

Arbitrary Rotation

  • Find a rotation matrix that rotates by

an angle  about an arbitrary unit direction vector v x z v v = (xv,yv,zv), xv

2+yv 2+zv 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

slide-9
SLIDE 9

Rotate v to z

  • 1. Project v onto the yz plane and

let d = sqrt(yv

2 + zv 2)

x y z v vyz v = (xv,yv,zv), xv

2+yv 2+zv 2=1

zv yv d

slide-10
SLIDE 10

Rotate v to z

  • 1. Project v onto the yz plane and

let d = sqrt(yv

2 + zv 2)

  • 2. Then cosfx = zv/d and sinfx = yv/d

x y z v vyz v = (xv,yv,zv), xv

2+yv 2+zv 2=1

zv yv d fx

slide-11
SLIDE 11

Rotate v to z

  • 1. Project v onto the yz plane and

let d = sqrt(yv

2 + zv 2)

  • 2. Then cosfx = zv/d and sinfx = yv/d
  • 3. Rotate v by fx about x into the xz plane

x y z v vyz v = (xv,yv,zv), xv

2+yv 2+zv 2=1

zv yv d fx

1 1

z y d d y z d d

                

v v v v

slide-12
SLIDE 12

Rotate v to z

  • 1. Project v onto the yz plane and

let d = sqrt(yv

2 + zv 2)

  • 2. Then cosfx = zv/d and sinfx = yv/d
  • 3. Rotate v by fx about x into the xz plane

x y z v vxz v = (xv,yv,zv), xv

2+yv 2+zv 2=1

fx

1 1

z y d d y z d d

                

v v v v

slide-13
SLIDE 13

Rotate v to z

  • 1. Project v onto the yz plane and

let d = sqrt(yv

2 + zv 2)

  • 2. Then cosfx = zv/d and sinfx = yv/d
  • 3. Rotate v by fx about x into the xz plane
  • 4. Then cosfy = d and sinfy = xv

x y z v vxz v = (xv,yv,zv), xv

2+yv 2+zv 2=1

fy 1 d xv

1 1

z y d d y z d d

                

v v v v

slide-14
SLIDE 14

Rotate v to z

  • 1. Project v onto the yz plane and

let d = sqrt(yv

2 + zv 2)

  • 2. Then cosfx = zv/d and sinfx = yv/d
  • 3. Rotate v by fx about x into the xz plane
  • 4. Then cosfy = d and sinfy = xv
  • 5. Rotate vxz by fy about y into the z axis

x y z v vxz v = (xv,yv,zv), xv

2+yv 2+zv 2=1

fy fx

1 1 1 1

z y d d y z d d

d x x d                              

v v v v

v v

slide-15
SLIDE 15

Rotate  about v

  • Let Rv() be the rotation matrix for

rotation by  about arbitrary axis direction v

  • Recall (Rx Ry) is the matrix

(product) that rotates direction v to z axis

  • Then

Rv() = (Ry Rx)-1 Rz() (Ry Rx) = Rx

  • 1 Ry
  • 1 Rz() Ry Rx

= Rx

T Ry T Rz() Ry Rx

(since the inverse of a rotation matrix is the transpose of the rotation matrix)

slide-16
SLIDE 16

Easier Way

  • Find an orthonormal vector system

x y z u v

slide-17
SLIDE 17

Easier Way

  • Find an orthonormal vector system

– Let r = u  v/||uv|| x y z u v r

slide-18
SLIDE 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’

slide-19
SLIDE 19

Easier Way

  • Find an orthonormal vector system

– Let r = u  v/||uv|| – Let u’ = v  r

  • Find a rotation

from <r,u’,v>  <x,y,z>

' 1 ' ' 1 1 1

x x x x y y y y z z z z

r u v r r u v r r u v r                                      1 ' ' ' 1 1 1

x y z x x y z y x y z z

r r r r u u u r v v v r                                       

x y z u v r u’

slide-20
SLIDE 20

Graphics Pipeline

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

W2V Persp View Model                                        

Screen Vertices Model Vertices

slide-21
SLIDE 21

Graphics Pipeline

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

W2V Persp View Model 1 1

s m s m m

x x y y z                                                                         

slide-22
SLIDE 22

Graphics Pipeline

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

1

s s

x y                    1

m m m

x y z                  

M

slide-23
SLIDE 23

Transformation Order

1

s s

x y                    1

m m m

x y z                  

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

1

s s

x y                    1

m m m

x y z                                          

M R T

1

s s

x y                    1

m m m

x y z                                          

M T R