Unit II TwoDimensional Transformations CONTENTS Introduction to transformations

  • Slides: 35
Download presentation
Unit II Two-Dimensional Transformations:

Unit II Two-Dimensional Transformations:

CONTENTS: • Introduction to transformations. • Transformation Matrix. • Types of Transformations in Two-Dimensional

CONTENTS: • Introduction to transformations. • Transformation Matrix. • Types of Transformations in Two-Dimensional Graphics • Translation, Rotation , Scaling. • Reflection and Shear Transformations • Rotation about an Arbitrary Point, • Combined Transformation • Homogeneous Coordinates • 2 D Transformations using Homogeneous Coordinates

INTRODUCTION: • Almost all graphical systems allow the programmer to define the picture that

INTRODUCTION: • Almost all graphical systems allow the programmer to define the picture that include a variety of transformations. • E. g. A programmer is able to magnify a picture so that detail appears more clearly. Or reduce it so that more of the picture is visible. • The programmer is also able to rotate the picture so that he can see it in different angles. • What is geometric transformation? • Operations that are applied to the geometric description of an object to change its position, orientation, or size are called geometric transformations.

 • Why do we need geometric transformations in CG( motivation )? • As

• Why do we need geometric transformations in CG( motivation )? • As a viewing aid • As a modeling tool • As an image manipulation tool

2 D Transformation of Graphics

2 D Transformation of Graphics

 • So the geometric-transformation functions that are available in some system are following:

• So the geometric-transformation functions that are available in some system are following: 1. 2. 3. 4. Translation Rotation Scaling Other useful transforms includes: reflection and shear.

1. Two-Dimensional(2 D) Translation :

1. Two-Dimensional(2 D) Translation :

 • Two-Dimensional(2 D) Translation: • We perform a translation on a single coordinate

• Two-Dimensional(2 D) Translation: • We perform a translation on a single coordinate point by adding offsets to its coordinates so as to generate a new coordinate position. • Similarly, a translation is applied to an object that is defined with multiple coordinate positions by relocating all the coordinate positions by the same displacement along parallel paths. • Suppose tx and ty is the translation distances, (x, y) is the original coordinates, is the new coordinate position.

 • Express the translation use matrix equation as following: • Translation is a

• Express the translation use matrix equation as following: • Translation is a rigid-body transformation that moves objects without deformation. • Ex: Translate a polygon with coordinates A(2, 5), B(7, 10), C(10, 2) by 3 units x direction and 4 units in y direction (Hint : Add 3 to all x values and 4 to all values).

2. Two-Dimensional Rotation:

2. Two-Dimensional Rotation:

Two-Dimensional Rotation • We generate a rotation transformation of an object by specifying a

Two-Dimensional Rotation • We generate a rotation transformation of an object by specifying a rotation axis and a rotation angle. All points of the object are then transformed to new positions by rotating the points through the specified angle about the rotation axis. • A 2 D rotation of an object is obtained by repositioning the object along a circular path in the xy plane, the rotation axis is perpendicular to the xy plane. • Parameters for 2 D rotation is rotation angle and a rotation point( pivot point). • Rotation angle define a positive values for counterclockwise rotation about the pivot point.

Diagram:

Diagram:

 • r is the constant distance of the point form the origin, angle

• r is the constant distance of the point form the origin, angle is the original angular position of the point from the horizontal, and is the rotation angle. (1) (2)

Put eq 1 in eq 2: (3)

Put eq 1 in eq 2: (3)

3. Two-Dimensional(2 D) Scaling: • Uniform Scaling • Un-uniform Scaling

3. Two-Dimensional(2 D) Scaling: • Uniform Scaling • Un-uniform Scaling

Two-Dimensional(2 D) Scaling • To alter the size of an object, we apply a

Two-Dimensional(2 D) Scaling • To alter the size of an object, we apply a scaling transformation. A simple two-dimensional scaling operation is performed by multiplying object positions (x, y) by scaling factors sx and sy to produce the transformed coordinate . • Scaling factors sx scales an object in the x coordinate.

 • Properties of the scaling transformation: • Any positive values can be assigned

• Properties of the scaling transformation: • Any positive values can be assigned to the scaling factors sx and sy. • Values less then 1 reduce the size of object. • In contrast , enlarge the size of object. • When sx and sy are assigned to the same values, a uniform scaling is produced which maintains relative object proportions.

 • Unequal values for sx and sy result in a differential scaling that

• Unequal values for sx and sy result in a differential scaling that is often used in design applications. • Negative values can also be specified for the scaling parameters, this not only resizes an object, it reflects the object one or more of the coordinate axis.

4. Reflection: Fig: Reflection about y axis • A reflection is a transformation that

4. Reflection: Fig: Reflection about y axis • A reflection is a transformation that produces the mirror image of an object relative to an axis of reflection. • We can choose an axis of reflection in the xy plane or perpendicular to the xy plane.

5. Shear: • A transformation that slants the shape of an object is called

5. Shear: • A transformation that slants the shape of an object is called as Shear transformation. • There are two types of transformations: 1. X shear 2. Y shear

1. X shear: • The X shear preserves the y coordinates but changes the

1. X shear: • The X shear preserves the y coordinates but changes the x values which causes vertical line to tilt right or left as shown in the fig: (a)original object (b)Object after X shear

2. Y shear: •

2. Y shear: •

Shearing relative to Other Reference line: • We can apply x shear and y

Shearing relative to Other Reference line: • We can apply x shear and y shear transformations relative to other reference line. • In X shear transformation we can use y reference line and in Y shear we can use x reference line

Homogeneous Coordinates: • In design and picture formation process, many times we may require

Homogeneous Coordinates: • In design and picture formation process, many times we may require to perform translation, rotation and scaling to fit the picture in their proper positions. • In fact, we can expressed three basic twodimensional transformation( translation, rotation, and scaling) in the general matrix form:

 • To produce a sequence of transformations such as translation followed by rotation

• To produce a sequence of transformations such as translation followed by rotation and then scaling, we must calculate the transformed coordinates one step at a time. • First, coordinates are translated then these translated coordinates are scaled and finally scaled coordinates are rotated. But this process is not efficient. • A more efficient approach is to combine sequence of transformations into one transformation so that final coordinate positions are obtained directly from initial coordinates. • This eliminates the calculation of intermediate coordinate values.

 • So, now we can say that the homogeneous coordinate allow combined transformation,

• So, now we can say that the homogeneous coordinate allow combined transformation, eliminating the calculation of intermediate values and thus save required time for transformation and memory required to store intermediate coordinate values.

Composition of 2 DTransformation: • We have seen what is meant by combined or

Composition of 2 DTransformation: • We have seen what is meant by combined or concatenated or composed transformation in the previous section. • The basic purpose of composing the transformation is to gain efficiency by applying a single composed transformation to a point rather than applying a series of transformations one after the other.

Rotation about an Arbitrary Point: •

Rotation about an Arbitrary Point: •

THANK U!!!!!

THANK U!!!!!