2D Transformation PDF
2D Transformation PDF
2D Transformation
مقدم لألستاذ
مهند هالل
اعداد الطالب
ماهر عصام علي
2019-2020
الكورس االول
Introduction
In Computer graphics,
Transformation is a process of modifying and re-positioning the existing graphics.
• 2D Transformations take place in a two dimensional plane.
• Transformations are helpful in changing the position, size, orientation, shape etc
of the object.
One of the most common and important tasks in computer graphics is to transform
the coordinates ( position, orientation, and size ) of either objects within the graphical
scene or the camera that is viewing the scene. It is also frequently necessary to
transform coordinates from one coordinate system to another, ( e.g. world
coordinates to viewpoint coordinates to screen coordinates. ) All of these
transformations can be efficiently and succintly handled using some simple matrix
representations, which we will see can be particularly useful for combining multiple
transformations into a single composite transform matrix.
Transformation Techniques
In computer graphics, various transformation techniques are-
Rotation in 2D
point (X,Y) is to be rotated about the origin by angle theta to location (X',Y')
note that this does involve sin and cos which are much more costly than addition or
multiplication
or P' = R * P where
_ _
P' = | X' |
| Y' |
- -
_ _
R = | cos(theta) -sin(theta) |
| sin(theta) cos(theta) |
- -
we will discuss about 2D Translation in Computer Graphics.
In Computer graphics,
2D Translation is a process of moving an object from one position to another in a two
dimensional plane.
1. Rotation: rotating an object about a fixed point without changing its size
or shape
Scaling
To change the size of an object, scaling transformation is used. In the scaling
process, you either expand or compress the dimensions of the object. Scaling can
be achieved by multiplying the original coordinates of the object with the scaling
factor to get the desired result.
Let us assume that the original coordinates are X,YX,Y, the scaling factors are (SX,
SY), and the produced coordinates are X′,Y′X′,Y′. This can be mathematically
represented as shown below −
X' = X . SX and Y' = Y . SY
The scaling factor SX, SY scales the object in X and Y direction respectively. The
above equations can also be represented in matrix form as below −
(X′Y′)=(XY)[Sx00Sy](X′Y′)=(XY)[Sx00Sy]
OR
P’ = P . S
Where S is the scaling matrix. The scaling process is shown in the following figure.
Composition of 2D Transformations
There are many situations in which the final transformation of a point is a
combination of several ( often many ) individual transformations. For example, the
position of the finger of a robot might be a function of the rotation of the robots hand,
arm, and torso, as well as the position of the robot on the railroad train and the
position of the train in the world, and the rotation of the planet around the sun, and .
If we provide values less than 1 to the scaling factor S, then we can reduce the size
of the object. If we provide values greater than 1, then we can increase the size of
the object.
Reflection
Reflection is the mirror image of original object. In other words, we can say
that it is a rotation operation with 180°. In reflection transformation, the size of the
object does not change.
The following figures show reflections with respect to X and Y axes, and about the
origin respectively.
Shear
A transformation that slants the shape of an object is called the shear
transformation. There are two shear transformations X-Shear and Y-Shear. One
shifts X coordinates values and other shifts Y coordinate values. However; in both
the cases only one coordinate changes its coordinates and other preserves its values.
Shearing is also termed as Skewing.
X-Shear
The X-Shear preserves the Y coordinate and changes are made to X coordinates,
which causes the vertical lines to tilt right or left as shown in below figure.
Y-Shear
The Y-Shear preserves the X coordinates and changes the Y coordinates which
causes the horizontal lines to transform into lines which slopes up or down as shown
in the following figure.
Reference