0% found this document useful (0 votes)
48 views

2 D Geometrical Transforms and Viewing Part 1 Eng 19

Uploaded by

Muhammad Usmaan
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
48 views

2 D Geometrical Transforms and Viewing Part 1 Eng 19

Uploaded by

Muhammad Usmaan
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 18

www.gradeup.

co

1 | Page
www.gradeup.co
2-D Geometric Transformation and Viewing Part-1

Content:

1. Transformations
2. Translation
3. Rotation
4. Scaling
5. Shearing

TRANSFORMATIONS

BASIC TRANSFORMATIONS

Consider the xy-coordinate system on a plane. An object (say Obj) in a place


can be considered as a set of points. Each object point P has coordinates (x,
y), so the object is the sum total of all its coordinate points (see in figure1). Let
the object be moved to a new position. Many coordinate points P’(x’, y’) of a
new object Obj’ can be obtained from the original points P(x, y) by the application
of a geometric transformation.

TRANSLATION

2 | Page
www.gradeup.co
It is the process of changing the position of an object. Let an object point P(x,
y) = xI + yJ be moved to P’(x’, y’) be the given translation vector V = t xI + tyJ,
where tx and ty is the translation factor in x and y directions, such that

P’ = P + V …………..(1)

In component form, we have

𝑥 ′ = 𝑥 + 𝑡𝑥 𝑎𝑛𝑑
𝑇𝑣 = { ……………(2)
𝑦 ′ = 𝑦 + 𝑡𝑦

Example: Translate a square ABCD with the coordinates

A(0, 0), B(5, 0), C(5, 5), D(0, 5) by 2 units in x-direction and 3 units in y-
direction.

Solution: we act as the given square, in matrix form, using homogeneous


coordinate of vertices

as:

The translation factors are, tx = 2, ty = 3

The transformation matrix for translation:

3 | Page
www.gradeup.co

New object point coordinates are:

[A’B’C’D’] = [ABCD].Tv

Thus, A’(x’1, y’1) = (2, 3)

B’(x’2, y’2) = (7, 3)

C’(x’3, y’3) = (7, 8)

D’(x’4, y’4) = (2, 8)

The graphical representation is given below:

ROTATION

In 2-D rotation, an object is rotated by an angle θ with respect to the origin.


This angle is supposed to be positive for anticlockwise rotation. There are two
cases for 2-D rotation, case 1- rotation about the origin and case 2 rotation about
an arbitrary point. If, the rotation is made about an arbitrary point, a set of basic

4 | Page
www.gradeup.co
transformation, i.e., composite transformation is required. For 3-D rotation involving
3-D objects, we need to specify both the angle of rotation and the axis of rotation,
about which rotation ahs to be made. We will consider case 1 and in the next
section we will consider case 2.

Before starting case-1or case-2 you must know the relationship between polar
coordinate system and Cartesian system:

Relation between polar coordinate system and Cartesian system

A frequently used non-cartesian system is Polar coordinate system. The following


below figure shows a polar coordinate reference frame. In polar coordinate system
a coordinate position is specified by r and θ, where r is a radial distance from
the coordinate origin and θ is an angular displacements from the horizontal (see
below figure). Positive angular displacements are counter clockwise. Angle θ is
measured in degrees. One complete counter-clockwise revolution about the origin
is treated as 3600. A relation between Catesian and polar coordinate system is
shown in below figure.

Consider a right angle triangle in above figure. Using the definition of trigonometric
functions, we transform polar coordinates to Cartesian coordinates as:

x = r.cosθ

y = r.sinθ

The inverse transformation from Cartesian to Polar coordinates is:

r = √(x2+y2) and θ = tan-1(y/x)

5 | Page
www.gradeup.co
Case 1: Rotation about the origin

Given a 2-D point P(x, y), which we want to rotate, with respect to the origin O.
the vector OP has a length ‘r’ and making a positive (anticlockwise) angle ɸ with
respect to x-axis.

Let P’(x’y’) be the result of rotation of point P by an angle ɸ about the origin,
which is shown in below figure.

P(x, y) = P(r.cosɸ, r.sinɸ)

P’(x’, y’) = P[r.cos(ɸ+θ), r.sin(ɸ+θ)]

The coordinates of P’ are:

x' = rsin(θ+ɸ) = r(cosθcosɸ - sinθsinɸ)

= x. cosθ – y.sinθ (where x = rcosɸ and y = rsinɸ)

Similarly,

y' = rsin(θ+ɸ) = r(sinθcosɸ + cosθ.sinɸ)

= xsinθ + ycosθ

Thus,

6 | Page
www.gradeup.co
Thus, we have obtained the new coordinate of point P after the rotation. In matrix
from, the transformation relation between P’ and P is given by:

This is P’ = P.Rθ ………….(5)

Where P’ and P acts as object points in 2-D Euclidean system and Rθ is


transformation matrix for anti-clockwise Rotation.

In terms of HCS, equation (5) becomes.

That is P’h = Ph.Rθ, ………....(7)

Where P’h and Ph acts as object points, after and before required transformation,
in Homogeneous Coordinates and Rθ is called homogeneous transformation matrix
for anticlockwise Rotation. P’h, the new coordinates of a transformed object, can
be found by multiplying previous object coordinate matrix, Ph, with the
transformation matrix for Rotation Rθ.

Note for clockwise rotation we have to put θ = -θ, thus the rotation matrix Rθ,
in HCS, becomes.

Example: Perform a 450 rotation of a triangle A(0, 0), B(1, 1), C(5, 2) about the
origin.

7 | Page
www.gradeup.co
Solution: We can act for the given triangle, in matrix form, using homogeneous
coordinates of the vertices:

So, the new coordinates A, B, C, of the rotation triangle ABC can be found as:

Thus, A’ = (0, 0), B’ = (0, √2), C’ = (3√2/2, 7√2/2)

The following below figure shows the original, triangle [ABC] and figure shows
triangle after the rotation.

8 | Page
www.gradeup.co

SCALING

It is the process of expanding or compressing the dimensions (i.e., size) of an


object. Important programing of scaling is in the development of viewing
transformation, which is a mapping from a window used to clip the scene to a
view port for displaying the clipped scene on the screen.

Let P(x, y) by any point of a given object and sx and sy by scalling factors in x
and y directions respectively, then the coordinate of the scaled object can be
obtained as:

x' = x.sx ….(8)

y’ = y. sy

if the scale factor is 0 < s < 1, then it reduces the size of an object and if it is
more than 1, it magnifies the size of the object along an axis.

For example, assume sx > 1.

i. Consider (x, y) → (2.x, y) i.e., Magnification in x-direction with scale factor sx =


2.

9 | Page
www.gradeup.co

ii. Similarly, assume sy > 1 and consider (x, y) → (x, 2.y), i.e. Magnification in y –
direction with scale factor sy = 2.

iii. Consider (x, y) → (x.sx, y) where 0 < sx = y2 < 1 i.e., Compression in x-direction
with scale factor sx = ½.

The general scaling is (x, y) → (x.sx, y.sy) i.e., magnifying or compression in


both x and y directions depending on Scale factors s x and sy. We can act this
in matrix form (2-D Euclidean system) as:

In terms of HCS, equation (9) becomes:

That is P’h = Ph.ssx,sy ……………(11)

10 | P a g e
www.gradeup.co
Example: Find the new coordinates of a triangle A(0, 0), B(1, 1), C(5, 2) after it
has been (a) magnified to twice its size and (b) reduced to half its size.

Solution: Magnification and reduction can be attained by a uniform scaling of s


units in both the x and y directions. If, s>1, the scaling produces magnification.
If, s<1, the result is a reduction. The transformation can be written as: (x,y,1) →
(s,x,s.y,1). In matrix form this becomes.

We can represent the given triangle, shown in below figure, in matrix form, using
homogeneous coordinates of the vertices as:

(a) choosing s = 2

So the new coordinates A’ B’ C’ of the scaled triangle ABC can be found as:

11 | P a g e
www.gradeup.co

Thus, A’ = (0, 0), B’ = (2, 2), C’ = (10, 4)

(b) Similarly, here, s = ½ and the new coordinates are A’’=(0, 0), B’’ = (1/2, 1/2),
C’’ = (5/2,1). The following figure (b) shows the effect of scaling with s k = sy =
2 and (c) with sx = sy = s = 1/2.

SHEARING

They are used for modifying the shapes of 2-D or 3-D objects. The effect of a
shear transformation looks like “pushing” a geometric object in a direction that is
parallel to a coordinate plane (3D) or a coordinate axis (2D). How far a direction
is pushed is determined by its shearing factor.

One familiar example of shear is that observed when the top of a book is moved
relative to the bottom which is fixed on the table.

In case of 2-D shearing, we have two types namely x-shear and y-shear.

In x-shear, one can push in the x-direction, positive or negative, and keep the
y-direction unchanged, while in y-shear, one can push in the y-direction and keep
the x-direction fixed.

12 | P a g e
www.gradeup.co
X-SHEAR ABOUT THE ORIGIN

Let an object point P(x, y) be moved to P’(x’, y’) in the x-direction, by the given
scale parameter ‘a’, i.e., P’(x’, y’) be the result of x-shear of point P(x, y) by
scale factor a about the origin, which is shown in below figure.

Thus, the point P(x, y) and P’(x’, y’) have the following relationship:

x' = x + ay

y’ = y = Shx(a) ….……(11a)

where ‘a’ is a constant (known as shear parameter) that measures the degree
of shearing. If a is negative then the shearing is in the opposite direction.

Note that P(0, H) is taken into P’(aH, H). It follows that the shearing angle A
(the angle through which the vertical adge was sheared) is given by:

Tan(A) = aH/H = a

So the parameter a is just the tan of the shearing angle. In matrix form (2-D
Euclidean system), we have

In terms of Homogeneous Coordinates, equation (12) becomes

13 | P a g e
www.gradeup.co
That is, P’h = PhSHx(a) ………..(14)

Where Ph and P’h represents object points, before and after required
transformation, in Homogeneous Coordinates and Sh x(a) is called homogeneous
transformation matrix for x-shear with scale parameter ‘a’ in the x-direction.

Y-SHEAR ABOUT THE ORIGIN

Let an object P(x, y) be moved to P’(x’, y’) in the x-direction, by the given scale
parameter ‘b’. i.e., P’(x’, y’) be the result of y-shear of point P(x, y) by scale
factor ‘b’ about the origin, which is shown in below figure.

Thus, the points P(x, y) and P’(x’, y’) have the following relationship:

x' = x

y’ = y + bx = Shy(b) ………..(15)

where ‘b’ is a constant (known as shear parameter) that measures the degree
of shearing. In matrix form, we have

In terms of Homogeneous Coordinates, equation (16) becomes.

14 | P a g e
www.gradeup.co
That is, P’h = Ph.Shy(b) ………..(18)

XY-SHEARS ABOUT THE ORIGIN

Let an object point P(x, y) be moved to P’(x’, y’) as a result of shear


transformation in both x and y directions with shearing factors a and b,
respectively, as shown in below figure.

The points P(x, y) and P’(x’, y’) have the following relationship:

x’ = x + ay

y’ = y + bx = Shxy(a, b) ………..(19)

where ‘ay’ and ‘bx’ are shear factors in x and y directions, respectively. The xy-
shear is also called simultaneous shearing for short.

In matrix form, we have,

In terms of Homogeneous Coordinates, we have

That is, P’h = Ph.Shxy(a, b) ………(22)

15 | P a g e
www.gradeup.co
Example: A square ABCD is given with vertices A(0, 0), B(1, 0), C(1, 1), and
D(0, 1). Illustrated the effect of a) x-shear b) y-shear and c) xy-shear on the
given square, when a = 2 an b = 3

Solution: We can represent the given square ABCD, in matrix form, using
homogeneous coordinates of vertices as:

a) The matrix of x-shear is:

So, the new coordinates A’B’C’D’ of the x-shear object ABCD can be found as:
[A’B’C’D’] = [ABCD]. Shx(a)

Thus, A’ = (0, 0), B’ = (1, 0), C’ = (3, 1) and D’ = (2, 1).

b) Similarly the effect shearing in the y direction can be found as: [A’B’C’D’] =
[ABCD].Shy(b)

Thus, A’ = (0, 0), B’ = (1, 3), C’ (1, 4) and D’ = (0, 1)

16 | P a g e
www.gradeup.co
c) Finally the effect of shearing in both directions can be found as: [A’B’C’D] =
[ABCD].Shxy(a, b)

thus, A’ = (0, 0), B’ = (1, 3), C’ = (3, 4) and D’ = (2, 1).

Figure (a) shows the original square, figure (b)-(d) shows shearing in the x, y
and both directions respectively.

17 | P a g e
www.gradeup.co

18 | P a g e

You might also like