Académique Documents
Professionnel Documents
Culture Documents
2-D Transformation
y
y x
Point representation
We can use a column vector (a 2x1 matrix) to represent a 2D point X Y A general form of linear transformation can be written as:
x = ax + by + c
X OR = Y 1 a d 0 b e 0 c f 1 * x y 1
y = dx + ey + f
Translation
Rigid body transformation that moves objects without deformation Re-position a point along a straight line Given a point (x,y), and the translation distance (tx,ty) The new point: (x, y) (x,y)
x = x + tx y = y + ty
= y x y
ty
(x,y)
tx
tx ty
Translation
To translate an object with multiple vertices
Rotation
Default rotation center: Origin (0,0)
> 0
< 0
: Rotate clockwise
Rotation
Rotation of (x,y) about origin by
(x,y)
(x, y)
(x, y)
(x,y)
x = r cos ( ) y = r sin ( )
x = r cos ( + ) y = r sin ( + )
Rotation
Rotation by transforms P(x,y) into x =P(x,y) ) y = r sin ( ) r cos (
x = r cos ( + ) y = r sin ( + ) x = r cos ( + ) = r cos( ) cos() r sin( ) sin() = x cos() y sin() y = r sin ( + ) = r sin( ) cos() + r cos( )sin() = y cos() + x sin()
(x,y) (x,y)
Rotation
Matrix form (Column Major order)
[X] = [X] [T] x y
=
cos() sin()
-sin() cos()
x y
cos()
Clockwise direction :
Rotation
Rotation of an object with multiple vertices
Scaling
Scale: Alter the size of an object by a scaling factor (Sx, Sy), i.e.
x = x . Sx y = y . Sy
(2,2) Sx = 2, Sy = 2 (1,1) (2,2)
x y
Sx 0 = 0 Sy
x y
(4,4)
Scaling
Uniform Scaling : if Sx = Sy
If Sx = Sy > 1, then uniform expansion i.e object becomes larger If Sx = Sy < 1, then uniform compression i.e object becomes smaller Object shape remains unaltered
Scaling
Non Uniform Scaling : depends whether Sx and Sy individually > 1 or < 1 but unequal Non Uniform Scaling also known as Differential Scaling Shape and size both change in differential scaling
Scaling
Pure uniform Scaling :
Factors < 1 moves objects closer to origin Factors > 1 moves objects farther form origin
A(40,2 2) (20,1 1) (26,1 1)
rm nifo ng 2 U i ca l = S= Sy Sx
D(52,2 2)
(20,5)
(26,5)
Shearing
When applied to any object results in distortion of shape
Opposite and parallel layers of object are slided with respect to each other
X - Shear
y co-ordinate remains unchanged 1 : Transformation matrix for shear 0 b 1
X Y = X
Y (0, 1) (1, 1) X
Y *
1 b
0 1
Y
= + Yb X
Shear (3, direction 1)
(2, 1)
(0, 0)
(1, 0)
(0, 0) (1, 0)
Y - Shear
x co-ordinate remains unchanged Transformation matrix for shear a 1 : 0 1
X Y = X Y * 1 0 a 1 =X
Shear directio n
Xa + Y
Reflection
Produces mirror image of an object Image formed on the side opposite to where the object is lying w.r.t mirror line Perpendicular distance of object to mirror line is same to the distance of the reflected image
C Mirror Line
C Reflected Object A
Y P (x, y) P (x, y) X
1 0
0 1
Rotation about y = x
Reflection of point P(x, y) about line y = x gives P(x, y) i.e. Y x = y y = x Transformation Matrix : X 0 1 1 0
Reflection about y = x
Reflection of point P(x, y) about line y = x gives P(x, y) i.e. Y x = y y = x Transformation Matrix : X 0 1 1 0
References
Introduction to Computer Graphics by Udit Aggarwal www.morehouse.edu www.cse.ohio-state.edu