3-D Transformational Geometry
CS418 Computer Graphics John C. Hart
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.
3-D Transformational Geometry
CS418 Computer Graphics John C. Hart
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
3-D Affine Transformations
3-D Coordinates
by 4-vectors
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)
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
3-D Rotations
– rotates y z
– rotates z x
– rotates x y
1 cos sin sin cos 1 cos sin 1 sin cos 1 cos sin sin cos 1 1
Arbitrary Axis Rotation
– Ensure ||v|| = 1 – Let o = (pv)v – Let a = p – o – Let b = v a, (note that ||b||=||a||) – Then p’ = o + a cos + b sin
to rotate all vertices in a meshed model x y z v
p p’ a b a b
p p’
||a||cos ||a||sin
Arbitrary Rotation
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
Rotate v to z
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
Rotate v to z
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 fx
Rotate v to z
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 fx
1 1
z y d d y z d d
v v v v
Rotate v to z
let d = sqrt(yv
2 + zv 2)
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
Rotate v to z
let d = sqrt(yv
2 + zv 2)
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
Rotate v to z
let d = sqrt(yv
2 + zv 2)
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
Rotate about v
rotation by about arbitrary axis direction v
(product) that rotates direction v to z axis
Rv() = (Ry Rx)-1 Rz() (Ry Rx) = Rx
= Rx
T Ry T Rz() Ry Rx
(since the inverse of a rotation matrix is the transpose of the rotation matrix)
Easier Way
x y z u v
Easier Way
– Let r = u v/||uv|| x y z u v r
Easier Way
– Let r = u v/||uv|| – Let u’ = v r x y z u v r u’
Easier Way
– Let r = u v/||uv|| – Let u’ = v r
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’
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
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 DistortionW2V Persp View Model 1 1
s m s m m
x x y y z
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 Distortion1
s s
x y 1
m m m
x y z
Transformation Order
1
s s
x y 1
m m m
x y z
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
1
s s
x y 1
m m m
x y z