0% found this document useful (0 votes)
97 views9 pages

Types of 2D Transformations in Graphics

The document discusses various types of 2D transformations including translation, rotation, scaling, reflection, shearing, and composite transformations. These transformations can be represented using transformation matrices and homogeneous coordinates allow multiple transformations to be combined into a single matrix multiplication.

Uploaded by

minimumpeacehelp
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
97 views9 pages

Types of 2D Transformations in Graphics

The document discusses various types of 2D transformations including translation, rotation, scaling, reflection, shearing, and composite transformations. These transformations can be represented using transformation matrices and homogeneous coordinates allow multiple transformations to be combined into a single matrix multiplication.

Uploaded by

minimumpeacehelp
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

2D Transformation

Transformation means changing some graphics into something else by applying


rules. We can have various types of transformations such as translation, scaling up
or down, rotation, shearing, etc. When a transformation takes place on a 2D plane, it
is called 2D transformation.

Transformations play an important role in computer graphics to reposition the


graphics on the screen and change their size or orientation.

Homogenous Coordinates
To perform a sequence of transformation such as translation followed by rotation and
scaling, we need to follow a sequential process −

Translate the coordinates,

Rotate the translated coordinates, and then


Scale the rotated coordinates to complete the composite transformation.

To shorten this process, we have to use 3×3 transformation matrix instead of 2×2
transformation matrix. To convert a 2×2 matrix to 3×3 matrix, we have to add an
extra dummy coordinate W.

In this way, we can represent the point by 3 numbers instead of 2 numbers, which is
called Homogenous Coordinate system. In this system, we can represent all the
transformation equations in matrix multiplication. Any Cartesian point PX, Y can be
converted to homogenous coordinates by P’ (Xh, Yh, h).

Translation
A translation moves an object to a different position on the screen. You can translate
a point in 2D by adding translation coordinate (tx, ty) to the original coordinate X, Y
to get the new coordinate ′
X ,Y

.
From the above figure, you can write that −

X’ = X + tx

Y’ = Y + ty

The pair (tx, ty) is called the translation vector or shift vector. The above equations
can also be represented using the column vectors.

[X] [X ] [tx ]
P = p' = ′
T=
[Y ] [Y ] [ty ]

We can write it as −

P’ = P + T

Rotation
In rotation, we rotate the object at particular angle θ theta from its origin. From the
following figure, we can see that the point PX, Y is located at angle φ from the
horizontal X coordinate with distance r from the origin.

Let us suppose you want to rotate it at the angle θ. After rotating it to a new
location, you will get a new point P’ ′
X ,Y

.
Using standard trigonometric the original coordinate of point PX, Y can be
represented as −

X = r cos ϕ. . . . . . (1)

Y = r sin ϕ. . . . . . (2)

Same way we can represent the point P’ ′


X ,Y

as −


x = r cos (ϕ + θ) = r cos ϕ cos θ − r sin ϕ sin θ. . . . . . . (3)


y = r sin (ϕ + θ) = r cos ϕ sin θ + r sin ϕ cos θ. . . . . . . (4)

Substituting equation 1 & 2 in 3 & 4 respectively, we will get


x = x cos θ − y sin θ


y = x sin θ + y cos θ

Representing the above equation in matrix form,

′ ′
cosθ sinθ
[X Y ] = [XY ] [ ] OR
−sinθ cosθ

P’ = P . R

Where R is the rotation matrix

cosθ sinθ
R = [ ]
−sinθ cosθ
The rotation angle can be positive and negative.

For positive rotation angle, we can use the above rotation matrix. However, for
negative angle rotation, the matrix will change as shown below −

cos(−θ) sin(−θ)
R = [ ]
−sin(−θ) cos(−θ)

cosθ −sinθ
= [ ] (∵ cos(−θ) = cosθ and sin(−θ) = −sinθ)
sinθ cosθ

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, Y , the scaling factors are (SX,
SY), and the produced coordinates are ′
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 X Sx 0
( ) = ( )[ ]

Y Y 0 Sy

OR

P’ = P . S

Where S is the scaling matrix. The scaling process is shown in the following figure.
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.
The transformation matrix for X-Shear can be represented as −

1 shx 0
⎡ ⎤
X sh = ⎢ 0 1 0⎥
⎣ ⎦
0 0 1

Y' = Y + Shy . X

X’ = X

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.

The Y-Shear can be represented in matrix from as −


1 0 0
⎡ ⎤
Y sh ⎢ shy 1 0⎥
⎣ ⎦
0 0 1

X’ = X + Shx . Y

Y’ = Y

Composite Transformation
If a transformation of the plane T1 is followed by a second plane transformation T2,
then the result itself may be represented by a single transformation T which is the
composition of T1 and T2 taken in that order. This is written as T = T1∙T2.

Composite transformation can be achieved by concatenation of transformation


matrices to obtain a combined transformation matrix.

A combined matrix −

[T][X] = [X] [T1] [T2] [T3] [T4] …. [Tn]

Where [Ti] is any combination of

Translation

Scaling
Shearing
Rotation
Reflection

The change in the order of transformation would lead to different results, as in


general matrix multiplication is not cumulative, that is [A] . [B] ≠ [B] . [A] and the
order of multiplication. The basic purpose of composing transformations is to gain
efficiency by applying a single composed transformation to a point, rather than
applying a series of transformation, one after another.

For example, to rotate an object about an arbitrary point (Xp, Yp), we have to carry
out three steps −
Translate point (Xp, Yp) to the origin.

Rotate it about the origin.


Finally, translate the center of rotation back where it belonged.

Common questions

Powered by AI

Shearing transformation differs from scaling and rotation because it alters the angle between the axes rather than changing the size or orientation of the object directly. In X-Shear, the Y coordinate remains the same while the X coordinate is adjusted based on a shear factor, causing vertical lines to tilt and skew the object horizontally . Meanwhile, Y-Shear affects the Y coordinate, preserving the X coordinate and slanting horizontal lines . The practical significance of shearing in graphics lies in its ability to mimic slant or skew effects, essential for creating perspective distortions and simulating the effect of light and shadow in a 2D plane without changing the object's actual dimensions .

The use of a homogenous coordinate system simplifies sequential transformations by allowing all transformation equations to be represented as matrix multiplications . This is preferable over the Cartesian system because it minimizes the complexity of applying multiple transformations such as translation, rotation, and scaling in sequence. The homogenous system introduces a dummy coordinate W, which enables the transformation of 2D points using a 3x3 matrix instead of a 2x2 matrix, thereby providing a unified framework for combining multiple transformations into a single composite transformation efficiently . This streamlines computation as one combined matrix can be used for the entire transformation process instead of transforming an object incrementally with separate matrices .

A 3x3 transformation matrix is used in homogenous coordinates to facilitate the representation of transformations as matrix multiplications, which can include a series of operations such as translation, rotation, and scaling . By using a third dummy coordinate, the matrix allows for affine transformations to be performed in a consistent form, which simplifies the mathematical operations needed for transformations. This setup is particularly advantageous for composite transformations because multiple transformations can be concatenated into a single matrix ([T] = [T1][T2]...[Tn]), reducing computational complexity and improving efficiency as only one matrix needs to be applied to each point on an object rather than a sequence of separate transformations .

Translation in composite transformations shifts an object's position on the 2D plane by adding a translation vector (tx, ty) to its original coordinates, moving it to a new location without altering its shape or orientation . When combined with other transformations like rotation or scaling, translation can significantly impact the final graphical result. For example, applying translation before rotation moves the center of rotation, changing how the object rotates relative to the original reference point. Similarly, translating an object before scaling affects the object's scale reference, altering the perceived scale effect . The sequence of translations in composite transformations is therefore critical, as it sets the context for subsequent operations, influencing the overall transformation effect and ensuring consistency across the graphical scene .

Reflection transformation differs from rotation and other transformations in that it creates a mirror image of the object relative to a specific axis. Mathematically, reflection can be seen as a rotation by 180° followed by a translation. Unlike rotation that changes an object's orientation by an angle θ without flipping it, reflection effectively flips the coordinates across an axis, reversing the direction of the reflected component. For example, reflecting over the Y-axis inverts the X coordinate (X' = -X) while maintaining the same Y coordinate (Y' = Y). This results in an image that is a mirror opposite of the original, altering its visual appearance without changing its size or shape .

A composite transformation matrix enhances efficiency in graphics rendering by consolidating multiple transformations into a single matrix operation. This reduces the computational complexity and processing time, as it requires fewer operations on each graphical object and minimizes the chances for cumulative errors across sequential transformations . However, the downside is that any error in the composite transformation matrix—such as from incorrect matrix component values or arithmetic rounding inaccuracies—can propagate throughout the rendering process. This could lead to distorted graphics, incorrect positioning, or unintended transformations that affect the visual integrity of the rendered scene . Careful handling of numerical precision and matrix configuration is therefore crucial to maintain accurate and consistent graphics rendering.

Scaling transformation affects an object's dimensions by proportionally increasing or decreasing its size based on scaling factors. These factors, denoted as SX for the X-axis and SY for the Y-axis, directly multiply the original coordinates of the object. When SX > 1, the object expands in the X direction; similarly, when SY > 1, the object expands in the Y direction. Conversely, values less than 1 for SX or SY will reduce the size of the object in the respective dimensions . This can be mathematically expressed with the equations: X' = X de6536e-58d0-11eb-9061-0242ac130003. SX and Y' = Y imes SY, altering the object's shape by modifying its spatial proportions without affecting its other properties such as orientation or the relative angles .

The order of performing 2D transformations significantly affects the final result because matrix multiplication, which represents these transformations, is not commutative ([A].[B] ≠ [B].[A]). For instance, if an object is translated first and then rotated, it will end up in a different position compared to rotating first and then translating. This occurs because translating changes the reference point for rotation, affecting how the rotation is applied relative to the object's position. Similarly, scaling before translation alters the magnitude of translation effects, whereas translating before scaling changes the distance from the origin that is scaled .

The use of matrix representations for composite 2D transformations offers significant advantages, such as computational efficiency and structured simplicity. By concatenating individual transformation matrices into a single composite matrix, transformations can be applied in one step rather than sequentially, reducing computational overhead and potential for cumulative rounding errors . Moreover, this approach provides a clear, unified framework for developers to understand and implement complex transformations. However, a potential limitation lies in the non-commutative nature of matrix multiplication, which can lead to different results based on the order of transformations. This requires careful consideration when designing transformation sequences to ensure the intended outcome . Additionally, rounding errors or inaccuracies in matrix values can propagate through calculations, potentially distorting graphics over multiple transformations .

Trigonometric functions such as sine and cosine are pivotal in rotation transformations as they describe the new coordinates of a point after rotation. When a point is rotated around the origin by an angle θ, its new coordinates (X', Y') are determined by: X' = X cos θ - Y sin θ, and Y' = X sin θ + Y cos θ. These equations derive from the basic formulas of circular motion, adjusting the point's position by projecting its distance from the origin onto the new axes formed by the rotation angle . The use of these trigonometric functions ensures that the point maintains its radius from the origin while rotating, preserving the object's overall shape and size but altering its orientation .

You might also like