Professional Documents
Culture Documents
2D Transformations
2D Transformations
• World Coordinates
• Translate
• Rotate
• Scale
• Viewport Transforms
• Putting it all together
Transformations
• Rigid Body Transformations - transformations that do
not change the object.
• Translate
– If you translate a rectangle, it is still a rectangle
• Scale
– If you scale a rectangle, it is still a rectangle
• Rotate
– If you rotate a rectangle, it is still a rectangle
Vertices
• We have always represented vertices as
(x,y)
• An alternate method is:
x
( x, y )
y
• Example:
2.1
(2.1,4.8)
4.8
Matrix * Vector
x' a b x x' a b c x
y ' c d y y ' d e f y
z ' g h i z
x' ax by x' ax by cz
y ' dx ey fz
y ' cx dy
z ' gx hy iz
1 0 0
1 0
I I 0 1 0
0 1 0 0 1
Matrix * Matrix
ax bz ay bw
A* B
cx dz cy dw
a b 1 0
? 0 1
c d
Practice
2 3 2
A ,X
1 5 3
AX ?
2 3 0.5 1
A ,B
1 5 3 2 .5
A* B ?
A* I ?
Translation
• Translation - repositioning an object along a
straight-line path (the translation
distances) from one coordinate location to
another. (x’,y’)
(tx,ty)
(x,y)
Translation
P (3.7,4.1)
P ( x, y )
• Given: T (7.1,8.2)
T (t x , t y )
(x’,y’)
(tx,ty)
(tx,ty)
(x,y) (x,y)
Recall
• A point is a position specified with
coordinate values in some reference frame.
• We usually label a point in this reference
point as the origin.
• All points in the reference frame are given
with respect to the origin.
Applying to Triangles
(tx,ty)
What do we have here?
• You know how to:
Scale
• Scale - Alters the size of an object.
• Scales about a fixed point
(x’,y’)
(x,y)
Scale
P ( x, y ) P (1.4,2.2)
• Given:
S (sx , s y ) S (3,3)
(x’,y’)
(x,y)
S=(1,2)
Rotation
• Rotation - repositions an object along a
circular path.
• Rotation requires an and a pivot point
Rotation
T ra n sfo rm a tion
W o rld -> S c re en
W o rld C o o rdin a te s
O b je c t # 1 O b jec t #2 O b jec t #3
O b jec t C oo rd in a tes O b je c t C oo rd in a tes O b jec t C oo rd in a tes
Let’s reexamine assignment 2b
Transformation Hierarchies
• For example:
Transformation Hierarchies
• Let’s examine:
Transformation Hierarchies
• What is a better way?
Transformation Hierarchies
• What is a better way?
Transformation Hierarchies W o rld C o o rdin a te s
T ra n sfo rm a tion
G re e n -> W o rld
T ra n sfo rm a tion
R e d -> G re en
R ed
O b jec t C o o rd in a te s
T ra n sfo rm a tion
B lu e -> R e d
B lue
O b jec t C o o rd in a te s
More Complex Models