Вы находитесь на странице: 1из 23

Transformations

• Translation
Straight line movement
• Rotation
Circular movement w.r.t pivot
• Scaling
Change of size
Translation
Y 6

4
4, 4

tx = 2 3
ty = 3
2

1
2, 1

0
1 2 3 4 5 6 7 8 9 10
X
Translation
• Translation Distances tx, ty
• For point P(x,y) after translation we have P′(x′,y′)
x′ = x + tx
y′ = y + ty

• (tx, ty) is Translation vector


Translation
 • Now x′ = x + tx , y′ = y + ty can be expressed as a
single matrix equation:
P′ = P + T
Where P = P′ = T =
Translation
• Rigid Body Transformation
• Objects are moved without deformation
• Every point on the object is translated by the
same amount
• Typically all the endpoints are translated and
object is redrawn using new endpoint positions
Rotation

Y
6

5
Ɵ = π/6
4

1 Ɵ

0
1 2 3 4 5 6 7 8 9 10
X
Rotation
• Repositions an object along a circular path in xy-
plane
• Rotation Angle θ
• Rotation Point (xr, yr)
• θ is +ve  counterclockwise rotation
• θ is -ve  clockwise rotation
• θ is zero  ?
Rotation
• For simplicity, consider the pivot at origin and
rotate point P (x,y)
where x = r cosФ and y = r sinФ
• If rotated by θ then:
• x′ = r cos(Ф + θ)
= r cosФ cosθ – r sinФ sinθ
and
• y′ = r sin(Ф + θ)
= r cosФ sinθ + r sinФ cosθ
Rotation
• Replacing r cosФ with x and r sinФ with y, we
have:
x′ = x cosθ – y sinθ

y′ = x sinθ + y cosθ
Rotation
• Column vector representation:
P′ = R . P
Where

 x' cos   sin    x


P'    R  P 
 y '  sin  cos    y
Rotation
• Rigid Body Transformation
• Objects are rotated without deformation
• Every point on the object is rotated by the same
angle
• Typically all the endpoints are rotated and object
is redrawn using new endpoint positions
Scaling

Y 6

Sx = 3 3
Sy = 2
2
 2 3
1 1  1 6  9 
     2  2
   
0
1 2 3 4 5 6 7 8 9 10
X
Scaling
• Scaling alters the size of an object
• Scaling factors Sx and Sy are used
• For polygons, coordinates of each vertex may be
multiplied by Sx & Sy to produce the transformed
coordinates:
x′ = x.Sx y′ = y.Sy
Scaling
• In matrix form it can be expressed as :
P′ = S.P

 x'  Sx 0   x 
 y '   0 Sy . y 
    
Scaling
• Scaling factor > 1
• Scaling factor < 1
• Scaling factor = 1

• Same valued scaling factors = uniform scaling


• Different valued scaling factors = differential scaling
Scaling
• This can be controlled by scaling w.r.t. a fixed point
(xf,yf)
x’ = xf + (x - xf)Sx
y’ = yf + (y - yf)Sy
• These can be rewritten as:
x’ = x. Sx + xf (1 – Sx)
y’ = y. Sy + yf (1 – Sy)
• Where the terms
xf (1 – Sx) and yf (1 – Sy) are constant for all points in the
object
Homogeneous Coordinates
• Translation:
P′ = P + T

• Rotation:
P′ = R . P

• Scaling:
P′ = S . P
Homogeneous Coordinates

P’ = M1 . P + M2
Reflection

• Mirror image of object relative to axis of reflection


• By rotating the object about axis of reflection by
180o
Shear

• distort the shape


• Effect is, of layers sliding off each other
• x direction shear
• y direction shear
Shear

Y
6
5

4 
4
3
2
1

0
1 2 3 4 5 6 7 8 9 10 X
Shear

x direction Shear
• x’ = x + shx . y
• y’ = y

y direction Shear
• x’ = x
• y’ = shy . x + y
Shear

x and y direction Shear

• x’ = x + shx . y
• y’ = shy . x + y

Вам также может понравиться