Object Modeling

advertisement
III 3D Transformation
Homogeneous Coordinates
• The three dimensional point (x, y, z) is
represented by the homogeneous coordinate
(x, y, z, 1)
• In general, the homogeneous coordinate (x, y,
z, w) represents the three dimensional point
(x/w, y/w, z/w)
• The
generalized
transformation
matrix:
a
d
[T ]  
g

l
b
e
i
m
c
f
j
n



p


3

3

3

1


q 



r










s

1 3
 1  1
III-1
Scaling
• In general, this is done with the equations:
xn = s x * x
yn = s y * y
zn = sz * z
• This can also be done with the matrix
multiplication:
 x n  s x
y   0
 n  
 zn   0
  
w   0
0
sy
0
0
0
sz
0
0
0  x 
0  y 
*
0  z 
  
1 w 
III-2
• Scaling can be done relative to the object
center with a composite transformation
• Scaling an object centered at (cx, cy, cz) is
done with the matrix multiplication:
 xn  1
 y  0
 n  
 zn  0
  
 w  0
0 0 c x  s x
1 0 c y   0
*
0 1 cz   0
 
0 0 1 0
0
sy
0
0
0
sz
0
0
0  1
0 0
*
0 0
 
1 0
0 0  cx   x 
1 0  c y   y 
*
0 1  cz   z 
  
0 0
1  w 
III-3
Shearing
• Equivalent to pulling faces in opposite
directions
•
III-4
III-5
III-6
III-7
III-8
Rotation
• Rotation can be done around any line or vector
• Rotations are commonly specified around the x,
y, or z axis
• A positive angle of rotation results in a
counterclockwise movement when looked at
from the positive axis direction
• The matrix form for rotation
– x axis
0
 x  1
 y  0 cos
 n  
 zn  0 sin
  
0
 w  0
0
 sin
cos
0
0  x 
0  y 
*
0  z 
  
1 w 
III-9
– y axis
 x n   cos
y   0
 
 zn   sin
  
w   0
0 sin
1
0
0 cos
0
0
0  x 
0  y 
*

0 z
  
1 w 
– z axis
 xn  cos
 y   sin
 n  
z  0
  
w   0
 sin
cos
0
0
0 0  x 
0 0  y 
*

1 0 z
  
0 1 w 
III-10
III-11
III-12
III-13
Reflection
• Reflection through the xy-plane:
• Reflection through the yz-plane:
• Reflection through the xz-plane:
III-14
III-15
III-16
Translations
• The amount of the translation is added to or
subtracted from the x, y, and z coordinates
• In general, this is done with the equations:
x n = x + tx
yn = y + ty
z n = z + tz
• This can also be done with the matrix
multiplication:
 xn  1
 y  0
 n  
 zn  0
  
 w  0
0 0 tx   x 
1 0 t y   y 
*
0 1 tz   z 
  
0 0 1  w 
III-17
III-18
III-19
III-20
III-21
III-22
Combining Transformations
• Matrices can be multiplied together to
accomplish multiple transformations with
one matrix
• A matrix is built with successive
transformations occurring from right to left
• A combination matrix is typically built from
the identity matrix with each new
transformation added by multiplying it on
the left of the current combination
III-23
Rotation about an Arbitrary
Axis in Space
• Assume an arbitrary axis in space passing
through the point ( x0 , y0 , z 0 ) with direction
cosines (c x , c y , c z ) and rotation about this axis
by some angle 
•
III-24
• Direction cosines:
III-25
• The complete transformation is:
III-26
III-27
III-28
III-29
III-30
III-31
Reflection through an
Arbitrary Plane
•
III-32
• The general transformation is:
III-33
III-34
III-35
III-36
III-37
Download