unit ii two-dimensional transformations :

35
Unit II Two-Dimensional Transformations:

Upload: lynne

Post on 06-Jan-2016

43 views

Category:

Documents


1 download

DESCRIPTION

Unit II Two-Dimensional Transformations :. 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, - PowerPoint PPT Presentation

TRANSCRIPT

Page 1: Unit  II Two-Dimensional  Transformations :

Unit II

Two-Dimensional Transformations:

Page 2: Unit  II Two-Dimensional  Transformations :

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• 2D Transformations using Homogeneous Coordinates

Page 3: Unit  II Two-Dimensional  Transformations :

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.

Page 4: Unit  II Two-Dimensional  Transformations :

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

• As a viewing aid• As a modeling tool• As an image manipulation tool

Page 5: Unit  II Two-Dimensional  Transformations :

2D Transformation of Graphics

Page 6: Unit  II Two-Dimensional  Transformations :

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

1. Translation2. Rotation 3. Scaling 4. Other useful transforms includes:

reflection and shear.

Page 7: Unit  II Two-Dimensional  Transformations :

1. Two-Dimensional(2D) Translation :

Page 8: Unit  II Two-Dimensional  Transformations :

• Two-Dimensional(2D) 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.

txxx y y ty

'( , ')x y

Page 9: Unit  II Two-Dimensional  Transformations :

• 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).

x x tx

y y ty

Page 10: Unit  II Two-Dimensional  Transformations :

2.Two-Dimensional Rotation:

Page 11: Unit  II Two-Dimensional  Transformations :

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 2D 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 2D rotation is rotation angle and a rotation point( pivot point).

• Rotation angle define a positive values for counterclockwise rotation about the pivot point.

),( rr yx

Page 12: Unit  II Two-Dimensional  Transformations :

Diagram:

Page 13: Unit  II Two-Dimensional  Transformations :

• 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.

cos

sin

x r

y r

cossinsincos)sin('

sinsin-coscos)cos('

rrry

rrrx

( 1)

( 2)

Page 14: Unit  II Two-Dimensional  Transformations :

cossin'

sincos'

yxy

yxx ( 3)

Put eq1 in eq 2:

cos sin

sin cosx y x y

Page 15: Unit  II Two-Dimensional  Transformations :
Page 16: Unit  II Two-Dimensional  Transformations :
Page 17: Unit  II Two-Dimensional  Transformations :

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

• Un-uniform Scaling

Page 18: Unit  II Two-Dimensional  Transformations :

Two-Dimensional(2D) 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.

),( rr yx

'

'x

y

x x S

y y S

0

0x

y

Sx y x y

S

Page 19: Unit  II Two-Dimensional  Transformations :

• 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.

Page 20: Unit  II Two-Dimensional  Transformations :

• 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.

Page 21: Unit  II Two-Dimensional  Transformations :
Page 22: Unit  II Two-Dimensional  Transformations :

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.

Page 23: Unit  II Two-Dimensional  Transformations :

5.Shear:

• A transformation that slants the shape of an object is called as Shear transformation.• There are two types of

transformations:1. X shear2. Y shear

Page 24: Unit  II Two-Dimensional  Transformations :

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

Page 25: Unit  II Two-Dimensional  Transformations :

• The transformation matrix for X shear is given as

X_sh=

=x+.y and

Page 26: Unit  II Two-Dimensional  Transformations :

2. Y shear:

• The Y shear preserves the x coordinates, but changes the y values which causes horizontal line to transform into lines which slopes up or down as shown in the fig:

• The transformation matrix for Y shear is given as Y_sh =

=y+.x and

Page 27: Unit  II Two-Dimensional  Transformations :

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

Page 28: Unit  II Two-Dimensional  Transformations :

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 two-dimensional transformation( translation, rotation, and scaling) in the general matrix form:

21' MPMP

Page 29: Unit  II Two-Dimensional  Transformations :

• 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.

Page 30: Unit  II Two-Dimensional  Transformations :

• In order to combine sequence of transformations we have to eliminate the matrix addition associated with the translation terms in

• To achieve this we have to represent this matrix as 3*3 matrix instead of 2*2 introducing an additional dummy coordinate W.

• Here, points are specified by three numbers instead of two.

• This coordinate system is called Homogeneous Coordinate System.

Page 31: Unit  II Two-Dimensional  Transformations :

• The homogeneous coordinate is represented by a triplet(, , W).

• Where,

x= and y=

• For 2Dtransformations we can have the homogeneous parameter W to be any non zero value. But it is convenient to have W=1.

• Hence,2D position can be represented with homogeneous coordinate as (x,y,1).

Page 32: Unit  II Two-Dimensional  Transformations :

• 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.

Page 33: Unit  II Two-Dimensional  Transformations :

Composition of 2DTransformation:

• 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.

Page 34: Unit  II Two-Dimensional  Transformations :

Rotation about an Arbitrary Point:

• To rotate an object about an arbitrary point(,),we have to carry out three steps:

1. Translate point (,) to the origin.2. Rotate it about the origin and3. Finally, translate the center of rotation back

where it belongs.

Page 35: Unit  II Two-Dimensional  Transformations :

THANK U!!!!!!!!!!