FCC Graficación CAD/CAM
3D Transformations
Contents
1. Translation 2. Scaling 3. Rotation 4. Other Transformations
1. Translation
y
( x' , y ' , z ' )
x' x Tx y ' y T y z ' z Tz x 1 y 0 z 0 1 0 0 0 Tx x 1 0 Ty y 0 1 Tz z 0 0 1 1
Ty (x, y, z) Tx Tz
x
z
P'TP
2. Scaling
y
( x' , y ' , z ' )
x ' x S x y ' y S y z ' z S z
(x, y, z)
∴
x
x S x y 0 z 0 1 0
0 Sy 0 0
0 0 Sz 0
0 x 0 y 0 z 1 1
z
P' SP
Sx S y Sz
Uniform scaling
Otherwise, non - uniform scaling
Relative Scaling
y y y y
( xF , yF , zF )
z
x
z
x
z
x
z
x
P'[T 1 ][ S ][T ]P where 1 0 T 0 0 0 0 xF S x 0 1 0 xF ,S 0 0 1 xF 0 0 1 0 0 Sy 0 0 0 0 Sz 0 0 1 0 0 , and T 1 0 0 1 0 0 0 xF 1 0 xF . 0 1 xF 0 0 1
3. Rotation
2D Rotation
( x' , y ' ) ( x' , y ' )
r r
q q
r
r
( x, y )
( x, y )
( xR , y R )
Rotation about z-axis is implicit !!!
y
∴
P' ( x' , y ' , z ' )
r
x' x cosq y sin q y ' x sin q y cosq z' z
q
r
P ( x, y, z )
x
z
x' cosq y ' sin q z' 0 1 0
sin q cosq 0 0
0 0 x 0 0 y 1 0 z 0 1 1
P' RZ P
By symmetry,
y y
x z
P' RX P, where 0 1 0 cosq RX 0 sin q 0 0 0 sin q cosq 0 0 0 0 1
x z
P ' RY P, where cosq 0 RY sin q 0 0 sin q 1 0 0 cosq 0 0 0 0 0 1
x' x y ' y cos q z sin q z ' y sin q z cos q
x' x cosq z sin q y ' y z ' xsin q z cosq
Rotation about an arbitrary axis
y
(x2, y2, z2)
u
(x1, y1, z1)
x z
Basic idea
T R
1. Translate the object so that the rotation axis passes through the origin. 2. Rotate the object so that the rotation axis coincides with one of the coordinate axis. 3. Perform the specified rotation. 4. R-1 5. T-1
x y z V ( x2 x1 , y2 y1 , z 2 z1 ) V u (a,b,c) V x x2 x1 , y y2 y1 , z z 2 z1 V x 2 y 2 z 2 x y z a , b , c V V V a 2 b 2 c 2 1
Step 1: Translation
y
(x2, y2, z2)
u u = (a, b, c) (x1, y1, z1)
x z
1 0 T 0 0 0 0 x1 1 0 y1 0 1 z1 0 0 1
Step 2: Aligning u with z-axis y
y
(0, b, c) = u'
u = (a, b, c)
a
(0, 0, 1) = uz
ux
x
a
d u'' = (a, 0, d)
x
z
u 'u z u x | u ' | | u z | sin a ux
2 2
z
b 2 c 2 sin a b b2 c2 d u' uz c cos a | u '|| u z | d sin a b
b c sin a
uy b 0 uz c u x (b) 1
ux u 'u z 0 0
1 0 0 c d Rx (a ) 0 b d 0 0
0 b d c d 0
0 0 0 1
y
y
uy
b
(0, 0, 1) = uz a d u'' = (a, 0, d)
x z
u' ' uz d | u ' '|| u z |
1 1
x
z
u y sin b ux u' ' uz a 0
∴ sin b a
u ' ' u z u y | u ' ' | | u z | sin b
cos b
uy 0 0
uz d 1
u y (a)
d 0 Ry (b ) a 0
0 a 0 1 0 0 0 d 0 0 0 1
∴ In Step 2,
R R y ( b ) Rx (a ) R 1 Rx (a ) 1 R y ( b ) 1
for later use
Step 3: Rotate about z-axis by a given angle
y
q
x z
cosq sin q Rz (q ) 0 0 sin q cosq 0 0 0 0 0 0 1 0 0 1
Step 4: [R-1] = [Rx(a)-1][Ry(b)-1] Step 5: [T-1]
∴ In summary,
P' T 1 Rx (a ) 1 R y ( b ) 1
z y x
R (q )R ( b )R (a )T P
4. Concatenation
The successive application of a number of transformations can be achieved with a single transformation matrix, the concatenation of the sequence. Suppose two transformations T1 and T2 are to be applied successively. The same effect can be achieved by the application of a single transformation T3, which is simply the product of the matrices T1 and T2. That is: The point (x, y, z) is transformed into (x’, y’, z’) by T1: [ x’ y’ z’ 1 ] = [ x y z 1 ] T1 (1) The point (x’’, y’’, z’’) is generated by applying T2: [ x’’ y’’ z’’ 1 ] = [ x’ y’ z’ 1 ] T2 (2) Substituting (1) in (2) gives: [ x’’ y’’ z’’ 1 ] = ([ x y z 1 ] T1)T2 = [ x y z 1 ] (T1T2) The order of application of the transformations must be preserved when the transformation matrices are multiplied together.