Documente Academic
Documente Profesional
Documente Cultură
Transformations
Lecture 4-6: Computer Aided Design and Manufacturing
Outline
y y
x x
Translate Scale
y
x
Rotate
Point representation
p' = T ( p)
( x ' , y ' ) = T ( x, y )
2D Translation
Re-position a point along a straight line
y = y + ty
x' x t x
OR p = p + t where p' = p= t=
y ' y t y
2D Translation
Translate individual
vertices
2D Rotation
Rotate with respect to origin (0,0)
(x, y) (x,y)
r
How to compute (x, y) ?
x = r cos () y = r sin ()
x = r cos ( + ) y = r sin ( + )
2D Rotation
x = r cos () y = r sin ()
x = r cos ( + ) y = r sin ( + ) (x,y)
x = r cos ( + ) (x,y)
r
= r cos() cos() r sin() sin()
= x cos() y sin()
y = r sin ( + )
= r sin() cos() +r cos() sin()
= y cos() + x sin()
2D Rotation
(x,y)
x = x cos() y sin()
y = y cos() + x sin()
r
(x,y)
Matrix form:
x =
cos() -sin() x
y sin() cos() y
2D Rotation
Rotate individual
Vertices
2D Scaling
x = x * Sx x Sx 0 x
=
y = y * Sy y 0 Sy y
(4,4)
(2,2) Sx = 2, Sy = 2
(2,2)
(1,1)
2D Scaling
(4,4)
(2,2) Sx = 2, Sy = 2
(2,2)
(1,1)
sx = -1 sy = 1 original
sx = -1 sy = -1 sx = 1 sy = -1
Put it all together
Translation as multiplication?
Can we use only tx and ty to make a multiplicative translation matrix?
(Boardwork derivation)
x' x
y ' = [?]* y
Translation Multiplication Matrix
x = x + tx
y y ty
Use 3 x 1 vector
x 1 0 tx x
y = 0 1 ty * y
1 0 0 1 1
3x3 2D Rotation Matrix
x =
cos() -sin() x (x,y)
y sin() cos() * y
r (x,y)
x =
cos() -sin() 0 x
y sin() cos() 0 * y
1 0 0 1 1
3x3 2D Scaling Matrix
x Sx 0 x
=
y 0 Sy y
x Sx 0 0 x
y = 0 Sy 0 * y
1 0 0 1 1
3x3 2D Matrix representations
Translation: x ' 1 0 tx x
y ' = 0 1 ty * y
1
0 0 1 1
x ' sx 0 0 x
Scaling: y ' = 0 sy 0 * y
1
0 0
1 1
Critical thinking transformations and matrix
multiplication
Suppose we want to scale an object, then translate it. What should the matrix multiplication look like?
A. p = Scale * Translate * p
B. p = Translate * Scale * p
C. p = p * Scale * Translate
D. Any of these is correct
Visualization of composing transformations
x' 1 0 0 x
y' = g 1 0 * y
1 0 0 1 1
Interesting Facts:
Any 2D rotation can be built using three shear transformations.
Shearing will not change the area of the object
Any 2D shearing can be done by a rotation, followed by a scaling, and followed by a
rotation
Local Rotation
The standard rotation matrix is used to rotate about the origin (0,0)
cos() -sin() 0
sin() cos() 0
0 0 1
(px,py)
Arbitrary Rotation Center
Translate the object so that P will coincide with the origin: T(-px, -py)
Rotate the object: R(q)
Translate the object back: T(px,py)
As a matrix multiplication
p = T[px,py] * R[q] * T[-px, -py] * P
Sx 0 0
0 Sy 0
0 0 1
(px,py)
Moving to 3D
Translation and Scaling are very similar, just include z dimension
1 0 0 0 cos() 0 sin() 0
0 0
Rx =
cos() sin() 0 1 0 0
0 sin() cos() 0 Ry =
sin() 0 cos() 0
0 0 0 1
0 0 0 1
3D Scaling
Sx 0 0 0
0 Sy 0
0
S=
0 0 Sz 0
0 0 0 1
Take home Problem:
In a CAD package, mirror image of a 2D point P ( 5, 10) , is to be obtained about a line which passes
through the origin and makes an angle of 45o counter-clockwise with the X -axis. Find the coordinates
of the transformed point.
38