Beruflich Dokumente
Kultur Dokumente
2D Translation
Repositioning an object along a straight line path from one co-ordinate location to another (x,y) (x,y) To translate a 2D position, we add translation distances tx and ty to the original coordinates (x,y) to obtain the new coordinate position (x,y) x= x + tx , y= y + ty Matrix form
y
x x t x = + t y y y P = P + T
P(x,y)
P(x,y)
r x
x = r. cos( + ) = r. cos . cos r. sin . sin y = r. sin( + ) = r. cos . sin + r. sin . cos
P(x,y)
P(x,y)
x = r. cos y = r. sin
x
r x
x = r. cos y = r. sin
Given us:
x cos y = sin
2D Scaling
Altering the size of an object. Sx and Sy are the scaling factors. If Sx = Sy then uniform scaling.
x = xS x y = yS y
Matrix form
x S x = 0 y P = S P
0 x Sy y
Sx = Sy =
x x Sx = Sy =
Reduced in size and moved closer to the origin
Transformations.
Translation.
P=T + P
Scale
P=S P
Rotation
P=R P
Homogeneous coordinates
If we represent (x,y,W) in 3-space, all triples representing the same point describe a line passing through the origin. If we homogenize the point, we get a point of form (x,y,1) homogenised points form a plane at W=1.
W=1 plane X Y
x 1 0 d x x y = 0 1 d . y y 1 0 0 1 1
x = x + d x y = y + d y 1=1
sx S (sx , s y ) = 0
0 sy
In homogeneous coordinates :
sx S (sx , s y ) = 0 0
0 sy 0
0 0 1
Matrix Representation
Use 33 matrices to combine transformations Translation
x 1 0 t x x y = 0 1 ty y 1 0 0 1 1 x cos y = sin 1 0 x S x y = 0 1 0 0 Sy 0 sin 0 x cos 0 y 0 1 1 0 x 0 y 1 1
Rotation
Scaling
Inverse Transformations
Translation
1 0 t x T 1 = 0 1 t y 0 0 1 cos sin 0 R 1 = sin cos 0 0 0 1
S1x 1 S = 0 0 0
1 Sy
Rotation
Scaling
0 0 1
Concatenation.
The matrix product T (d x1 , d y1 ) T (d x 2 , d y 2 ) is : 1 0 d x1 1 0 d x 2 1 0 d x1 + d x 2 0 1 d .0 1 d = 0 1 d + d y1 y2 y1 y2 0 0 1 0 0 1 0 0 1
Matrix product is variously referred to as compounding, concatenation, or composition. This single matrix is called the Coordinate Transformation Matrix or CTM.
Example
Consider the line with endpoints (10, 10) and (30, 25). Translate it by tx = -20, ty = -10 and then rotate it by = 90.
y
(30, 25)
(10, 10)
Right-to-left
x cos 90 sin 90 0 1 0 20 x y = sin 90 cos 90 0 0 1 10 y 1 0 0 10 0 1 1
Solution
x cos 90 sin 90 0 1 0 20 x y = sin 90 cos 90 0 0 1 10 y 1 0 0 10 0 1 1 0 1 0 1 0 20 x = 1 0 0 0 1 10 y 0 0 10 0 1 1 0 1 10 x = 1 0 20 y 0 0 1 1
y
(30, 25)
(10, 10)
Solution (continue)
x 0 1 10 x y = 1 0 20 y 1 0 0 1 1
y
(30, 25) (-15, 10) (10, 10) (0, -10)
Exercises
Consider the following object:
y
25 10 10 45
Apply a rotation by 145 then scale it by Sx=2 and Sy=1.5 and then translate it by tx=20 and ty=-30.