Module 3
Module 3
2D Transformations
The ability to change the geometry of each object by changing its size,
position, or orientation. These operations are called geometric
transformations.
The changes in orientation, size, and shape are accomplished with
geometric transformations that alter the coordinate descriptions of
objects.
Transformation refers to the mathematical operations or rules that are
applied on a graphical image consisting of the number of lines, circles,
and ellipses to change its size, shape, or orientation.
When a transformation takes place on a 2D plane, then it is known as 2D
transformation.
Transformations play an important role in computer graphics to
reposition the graphics on the screen and change their size or
orientation.
Types of Transformations
1. Translation
2. Scaling
3. Rotating
4. Reflection
5. Shearing
Translation, Scaling, and Rotation are also known as basic transformations.
Reflection and Shearing are often applied to objects.
Translation
Line
Rectangle
Polygon
Square
Circle
The Translation equation can be represented as Matrix Form:
tx defines the distance the x coordinate has to be moved and t y defines the
distance the y coordinate has to be moved.
This translation is achieved by adding the translation coordinates to the old
coordinates of the object:
Given a circle C with radius 10 and center coordinates (1, 4). Apply the
translation with distance 5 towards X axis and 1 towards Y axis. Obtain the new
coordinates of C without changing its radius.
Solution:
Given:
Example 2:
Given a square with coordinate points A(0, 3), B(3, 3), C(3, 0), D(0, 0). Apply the
translation with distance 1 towards X axis and 1 towards Y axis. Obtain the new
coordinates of the square.
Solution:
Given:
The scaling factor sx, sy scales the object in X and Y direction respectively.
(sx, sy) > 1: Enlarge the object size
(sx, sy) = 1: Object with same size
(sx, sy) < 1: Reduce the object size
If scaling factors with values less than one will move the object closer to
the origin. If scaling factors with values less than one will move the
coordinate position farther from the origin.
We can apply Scaling on the following objects:
Straight Lines
Curved Lines
Polygon
Circle
The Scaling equation can be represented as Matrix Form:
P’ = P.S
i.e. P’ = S.P
Example:
A Square object with the coordinate points P (1, 4), Q (4, 4), R (4, 1), T (1,1).
Apply the scaling factor 3 on the X-axis and 4 on the Y-axis. Find out the new
coordinates of the square.
Solution:
Coordinates Points for Square:
P = (1, 4), Q = (4, 4), R = (4, 1), and S = (1, 1)
x’ = x * sx = 1 x 3 = 3
y’ = y * sy = 4 x 4 = 16
The new Coordinates, P = (3, 16)
For Coordinate Q = (4, 4)
x’ = x * sx = 4 x 3 = 12
y’ = y * sy = 4 x 4 = 16
The new Coordinates, Q = (12, 16)
For Coordinate R = (4, 1)
x’ = x * sx = 4 x 3 = 12
y’ = y * sy = 1 x 4 = 4
The new Coordinates, R = (12, 4)
For Coordinate S = (1, 1)
x’ = x * sx = 1 x 3 = 3
y’ = y * sy = 1 x 4 = 4
The new Coordinates, S = (3, 4)
To make scaling simpler, the object is shifted (translated) so that the fixed point
(xf, yf) aligns with the origin (0, 0).
Step 3: Scaling Around the Origin:
Once the fixed point is at the origin, the object is scaled using the scaling
factors sx and sy relative to the origin. This changes the size of the object but
keeps the fixed point (at the origin) stationary.
Step 4: Translate Back to the Original Position:
Finally, the object is shifted back (translated) so that the fixed-point returns to
its original position (xf, yf).
Pivot Point
A pivot point is a specific location on or near an object that serves as the
reference point for transformations such as Scaling, Rotation, and Translation.
It acts as the anchor or center of control, determining how and where these
transformations are applied.
Example:
Straight Lines
Curved Lines
Polygon
Circle
The Rotation of any object depends upon the two points.
Example:
The negative value of the rotation angle rotates an object in the clockwise
direction. To generate a new rotation point based on the current point is
x’= x*cosθ + y*sinθ
y’= -x*sinθ + y*cosθ
Matrix representation is:
P’ = P*R(-θ)
It is written as P’ = R(-θ) *P
Example:
Rotation about an arbitrary/general pivot point
Steps:
Step 1: Translate the object so that the pivot point is moved to the coordinate
origin.
Step 2: Rotate the object about the origin
Step 3: Translate the object so that the pivot point is returned to its original
position.
Rotation
It is a transformation which produces a mirror image of an object. In the
Reflection process, the size of the object does not change. The object is rotated
by180°.
Types of Reflection
1. Reflection along x-axis
In this kind of Reflection, the value of x is positive, and the value of y is
negative. The object will lie another side of the x-axis.
x’= x or x = x * 1
y’= -y or y = y * -1
Matrix representation:
P’= P * Rx
It is written as P’= Rx * P
Example:
Matrix Representation:
P’ = P * Ryx
It is written as P’ = Ryx * P
Example:
Shearing
Shearing is the transformation of an object which changes the shape of the
object. The shearing can be in one direction or two directions. Shearing is also
termed as Skewing. Shearing can be done in three ways:
1. Shearing in the x-direction (x-shear)
The x-shear preserves the y coordinate and changes are made to x
coordinates only. It is also called Horizontal Shearing.
Shearing in x-axis can be done using this equation:
x’ = x + Shx * y
y’ = y
Matrix representation is
P’= Shx * P
Example: