Unit – 3
2D Transformation
The transformation means the translating some graphics into something else.
It has some rules to apply on the changing graphics.
Some transformations are such as translation, scaling up or down, shearing, rotating etc.
The transformation that applies on the 2D plane this is called as 2D transformation.
It is important in computer graphics to reposition the graphic on the screen and change their size or orientation.
The term "transformation" refers to the process of applying rules to change one set of visuals into another. Different forms of transformations are possible, such as translation, scaling up or down, rotation, shearing, and so on. The term "2D transformation" refers to a transformation that occurs on a two-dimensional plane.
In computer graphics, transformations are used to rearrange graphics on the screen and modify their size or orientation.
Key takeaway
The term "transformation" refers to the process of applying rules to change one set of visuals into another. Different forms of transformations are possible, such as translation, scaling up or down, rotation, shearing, and so on.
The term "2D transformation" refers to a transformation that occurs on a two-dimensional plane.
Following are the 2D transformations in computer graphics.
3.2.1 Translation
The translation process is used to move an abject to the different position on the screen.
The translation done by adding translation coordinates (tx,ty) to the original coordinates.
The figure shows the translation process.
Fig 1: Translation
In the figure,
X’=X+tx
Y’=Y+ty
The pair (tx,ty) is called the translation vector or shift vector.
The equation can be represent by column vector.
3.2.2 Scaling
The scaling transformation is done for changing the size of abject.
The dimension of the abject can be compress or expand by using scaling.
The scaling can be achieved by multiplying the original coordinates with the scaling factor to get the desired result.
The scaling factors be Sx and Sy with respt to x and y coordinates.
If the value assigned to the scaling factor S is less than 1 then the size of the abject will compressed.
If the value assigned to the scaling factor S is greater than 1 then the size of the abject will increased.
Following figure shows the scaling process.
Fig 2: Scaling
Let assume that the original coordinates are X and Y and the scaling factors are (Sx,Sy).
The mathematics representation of the scaling represented as shown below:
X’=X * Sx
And Y’=Y * Sy
The above equation can be represented in matrix form as shown below:
And
3.2.3 Rotation
The rotation is used for rotating the object at particular angle Ꙫ from its origin.
The following figure shows the point P that is located at angle ф from the horizontal X coordinate with distance r from the origin.
Fig 3: Rotation
The rotation is achieved by using the following rotation equation:
X’=X * cos - Y * sin
Y’ =X * sin + Y * cos
In matrix for, the clockwise rotation represented as shown below:
In matrix for, the anti-clockwise rotation represented as shown below:
The homogeneous coordinates will be represented as:
Fig 4: Matrix representation
Homogeneous coordinates
A point, a straight line, or a full image on the screen can be rotated around a point other than the origin by first moving the image until the point of rotation occupies the origin, then rotating the image, and then moving the image back to its original location.
A translation is the process of shifting a picture from one location to another in a straight line. A translation can be done by adding or subtracting the amount that the picture has to be displaced from each location.
The use of a simple matrix application to translate a point by changing its coordinates cannot be combined with additional transformations. If we want to rotate an image around a point other than the origin by translation, rotation, and translation, we'll need this combination.
Homogeneous coordinates are used to merge these three transformations into a single transformation. Two-dimensional coordinate positions (x, y) are represented by triple-coordinates in a homogeneous coordinate system.
In most design and construction applications, homogeneous coordinates are used. To put the picture into the right place, we execute translations, rotations, and scaling here.
The homogeneous coordinates are used to perform any transformation such as the translation followed by rotation and the scaling.
The translation follows the sequential process as-
● Translate the coordinates
● Rotate the translated coordinates
● Scale the rotated coordinates to complete the transformation
The process can be shortened by using the matrix of 3*3 instead of using matrix 2*2. This matrix is called a transformation matrix.
To convert 2*2 matrix in 3*3 we have to add just coordinate w.
In this way, the representation of points by 3 numbers instead of 2 numbers, is known as the homogeneous coordinates.
We can represent all the transformation by using homogeneous coordinates in matrix multiplication.
Any Cartesian point can be converted to homogeneous coordinates by P’ (Xh, Yh, h)
Example
We can set the homogeneous parameter h to any non-zero value for two-dimensional geometric transformation. Take it as one for the sake of convenience. The homogeneous coordinates are then used to represent each two-dimensional point (x, y, 1).
The matrix for two-dimensional transformation in homogeneous coordinate is as follows:
Key takeaway
Homogeneous coordinates are used to merge these three transformations into a single transformation.
A translation is the process of shifting a picture from one location to another in a straight line. A translation can be done by adding or subtracting the amount that the picture has to be displaced from each location.
The use of a simple matrix application to translate a point by changing its coordinates cannot be combined with additional transformations. If we want to rotate an image around a point other than the origin by translation, rotation, and translation, we'll need this combination.
Homogeneous coordinates are used to merge these three transformations into a single transformation. Two-dimensional coordinate positions (x, y) are represented by triple-coordinates in a homogeneous coordinate system.
In most design and construction applications, homogeneous coordinates are used. To put the picture into the right place, we execute translations, rotations, and scaling here.
Example
An example of how to represent coordinates in a homogeneous coordinate system is as follows: We can set the homogeneous parameter h to any non-zero value for two-dimensional geometric transformation. Take it as one for the sake of convenience. The homogeneous coordinates are then used to represent each two-dimensional point (x, y, 1).
The matrix for two-dimensional transformation in homogeneous coordinate is as follows:
Reflection Transformation
All the points are reflected or flipped on a line called axis reflection or line of reflection.
The reflection can be referred to as an axis of symmetry or mirror line.
The reflected diagram is the same as the original diagram is known as isometric transformation.
The reflected diagram is facing in opposite direction.
Following figure shows the reflection transformation.
Fig. 5
Shearing Transformation
The shear transformation is used for slanting the shape of the object.
Shearing is also known as skewing.
There are two shear transformations X-shear and Y-shear.
The X-shear shifts the X coordinates and the Y-shear shifts the Y coordinates.
In both cases only one coordinate changes and the other preserves.
X-shear:
It preserves the Y coordinate and changes made with the X coordinate.
Hence only vertical lines of the object get tilt on the right or left side as shown in the below figure:
Fig 6
The transformation matrix for X- shear:
Y’=Y + Shy * X and X’=X
Y-shear:
It preserves the X coordinates and makes changes with the Y coordinates.
The horizontal line of the object slopes toward up or down as shown in the below figure:
Fig 7
The transformation matrix for X- shear:
X’=X + Shx * Y and Y’=Y
Key takeaway
All the points are reflected or flipped on a line called axis reflection or line of reflection.
The reflection can be referred to as an axis of symmetry or mirror line.
A point, a straight line, or a full image on the screen can be rotated around a point other than the origin by first moving the image until the point of rotation occupies the origin, then rotating the image, and then moving the image back to its original location.
Computer graphics allow you to observe objects from many perspectives. The architect can look at a building from several perspectives, for example.
● Front Evaluation
● Side elevation
● Top plan
Charts and topographical maps can be resized by a cartographer. As a result, if visual images are encoded as numbers, the numbers can be saved in memory. Transformation is a mathematical operation that modifies certain numbers.
The goal of using computers for drawing is to allow users to observe objects from various angles, extending or lowering the scale or shape of the object, which is known as transformation.
The following are two crucial characteristics of transformation:
● Each change is treated as a separate entity. A distinct name or symbol might be used to identify it.
● After linking two transformations, a single transformation can be obtained, for example, A is a translation transformation. Scaling is done via the B transformation. C=AB is the result of combining the two. As a result of the concatenation property, C is obtained.
For explaining object transformation, there are two complimentary ways of view.
● Geometric Transformation - The object is transformed in relation to the background or coordinate system. Geometric transformations applied to each point of the object define the mathematical description of this viewpoint.
● Coordinate Transformation: While the coordinate system is altered relative to the object, the object is held immobile. The use of coordinate transformations is used to achieve this effect.
Here's an example of how these two points of view can be distinguished:
The motion of a car against a beautiful backdrop. We can do so by simulating
● Moving the car while keeping the background in place- (Geometric Transformation).
● We can keep the car in working order while changing the scenery in the background- (Coordinate Transformation).
Key takeaway
A point, a straight line, or a full image on the screen can be rotated around a point other than the origin by first moving the image until the point of rotation occupies the origin, then rotating the image, and then moving the image back to its original location.
References:
- Donald Hearn and Pauline Baker Computer Graphics, Prentice Hall, New Delhi, 2012
- Steven Harrington, "Computer Graphics- A programming approach", McGraw 3. Hill, 2nd Edition, 1987.
- Foley J.D., Van Dam A, "Fundamentals of Interactive Computer Graphics", Addison Wesley, 1990