1. 2-D Transformations
• Points and lines that joins them, with appropriate drawing
algorithms, represents objects/information graphically.
• Ability to transform these points and lines is basic to
computer graphics.
• In 2-D Objects, transformation is to change the objects:
- Position (Translation)
- Size (Scaling)
- Orientation (Rotation)
- Shapes (Shear)
- Reflection (Mirror image)
2. Point Representation
• A Point is represented in 2-Dimensions by its coordinates.
• We can use a column vector (a 2x1 matrix) or row vector(1x2)
to represent a 2D point : or [x y]
• Row matrices or column matrices are frequently called
position vectors.
• Series of points, each of which is position vectors relative to
some coordinate system is stored in computer as a matrix or
array of numbers.
• Lines are drawn between the points to generate lines, curves
or pictures.
3. Transformation of Points
• [X][T] = [x y] [ ]= [ (ax + cy) (bx + dy)] = [x’ y’]
Where, x’ = (ax + cy) and y’ = (bx + dy)
Case 1: Let, a=d=1 & c=b=0. The transformation matrix [T], then
reduces to the identity matrix. Thus,
[X][T] = [x y] [ ]= [x y] = [x’ y’],no changes as multiplying
with identity matrix gives us same result.
Case 2: Let, d=1, b=c=0,then,
[X][T] = [x y] [ ]= [ax y] = [x’ y’],
where x’ = ax, produces a scale change in x component.
a b
c d
1 0
0 1
a 0
0 1
4. Case 3: Let, b=c=0, i.e.,
[X][T] = [x y] [ ]= [ax dy] = [x’ y’], resulting in scaling
of both x and y components.
- If a ≠ d, means scaling are not equal.
- If a = d > 1, pure enlargement/scaling of coordinates occurs.
- If 0 < a = d < 1, compression of coordinates of point P occurs.
a 0
0 d
5. Case 4: If a and/or d are negative, then reflection through a
plane or axis can be seen. Let b=c=0, d=1,a= -1, then
[X][T] = [x y] [ ]= [-x y] = [x’ y’], reflection through y-
axis results.
- If b=c=0, a=1,d= -1,reflection through x-axis.
- If b=c=0,a=d<0, reflection through origin occurs.
-1 0
0 1
6. Case 5: let a=d=1,c=0,thus
[X][T] = [x y] [ ]= [x (bx+y)] = [x’ y’], it causes
shearing effect. Here x’ is unchanged, but y’ depends on y.
- if a=d=1,b=0. produces shear proportional to y coordinate.
1 b
0 1
7. Straight line transformation
• Position vector are: [A]=[0 1], [B]=[2 3]
• Let transformation matrix, [T] = [ ],due to shearing
effect.
1 2
3 1
8. • Transforming the position vectors for A & B using [T] produces new
vectors A’ and B’ given by:
[A] [T]= [0 1] [ ] = [3 1] = [A’] , and
[B] [T]= [2 3] [ ] = [11 7] = [B’]
• Resulting coordinates for new point A’ are x’=3, y’=1 and B’ are
x’= 11 and y’=7.
• From the Fig., Shearing transformation [T] increased the length of
the line and changes its orientation.
1 2
3 1
1 2
3 1
11. Transformation of Parallel lines
• If a 2x2 matrix is used to transform a pair of parallel lines, the
result is a second pair of parallel lines
12. Transformation of Intersecting lines
• When two intersecting lines are transformed using general
2x2 transformation matrix the resulting lines are also
intersecting. Consider 2 intersection lines
• Points of intersection:
• Transformed point of intersection:
15. • 2D Rotation
– If θ is positive counterclockwise rotation
– If θ is negative clockwise rotation
– Remember:
• cos(a + b) = cos a cos b - sin a sin b
• cos(a - b) = cos a sin b + sin a cos b
– At first, suppose the pivot point is at the origin
– x’=r cos(θ+Φ) = r cos θ cos Φ - r sin θ sin Φ
y’=r sin(θ+Φ) = r cos θ sin Φ + r sin θ cos Φ
– Let, x = r cos Φ, y = r sin Φ
– x’=x cos θ - y sin θ
y’=x sin θ + y cos θ
16. • 2D Rotation
– P’=R·P, where P is the point with coordinate (x,y) and P’ is
the new point with coordinate (x’,y’).
cos
sin
sin
cos
R
Φ
(x,y)
r
r θ
(x’,y’)
17. • 2D Rotation
– Rotation of a point about any specified position (xr,yr)
x’=xr+(x - xr) cos θ – (y - yr) sin θ
y’=yr+(x - xr) sin θ + (y - yr) cos θ
- Rotations also move objects without deformation
– A line is rotated by applying the rotation formula to each
of the endpoints and redrawing the line between the new
end points
– A polygon is rotated by applying the rotation formula to
each of the vertices and redrawing the polygon using new
vertex coordinates
18. • 2D Inverse Rotation Matrix
• And also:
1
0
0
0
cos
sin
0
sin
cos
1
R
I
R
R
*
1
19. Reflection
• Reflection
– Image is generated relative to an axis of reflection by
rotating the object 180° about the reflection axisect
– Transformation that produces a mirror image of an object
– Reflection about the line y=0 (the x axis)
[T] =
1
0
0
0
1
0
0
0
1
20. • Reflection about the line x=0 (the y axis)
[T] =
• Reflection about the origin
[T] =
1
0
0
0
1
0
0
0
1
23. Scaling
• 2D Scaling
– Scaling is used to alter the size of an object
– Simple 2D scaling is performed by multiplying object
positions (x, y) by scaling factors sx and sy
x’ = x · sx
y’ = y · sy
• or P’ = S·P
y
x
s
s
y
x
y
x
0
0
'
'
24. • 2D Scaling
– Any positive value can be used as scaling factor
• Values less than 1 reduce the size of the object
• Values greater than 1 enlarge the object
• If scaling factor is 1 then the object stays unchanged
• If sx = sy , we call it uniform scaling
• If scaling factor <1, then the object moves closer to the
origin and If scaling factor >1, then the object moves
farther from the origin
25. • 2D Scaling
– We can control the location of the scaled object by
choosing a position called the fixed point (xf,yf)
x’ – xf = (x – xf) sx y’ – yf = (y – yf) sy
x’=x · sx + xf (1 – sx)
y’=y · sy + yf (1 – sy)
– Polygons are scaled by applying the above formula to each
vertex, then regenerating the polygon using the
transformed vertices
26. Composite transformation
• We can setup a sequence of transformations as a composite
transformation matrix by calculating the product of the
individual transformations
• P’=M2·M1·P
=M·P
• Composite 2D Translations
– If two successive translation are applied to a point P, then
the final transformed location P' is calculated as