• No results found

are not equal, they have the effect of distorting pictures by

N/A
N/A
Protected

Academic year: 2022

Share "are not equal, they have the effect of distorting pictures by"

Copied!
20
0
0

Loading.... (view fulltext now)

Full text

(1)

UNIT- 3

rd

2D Transformation:-

A graphic system should allow the programmer to define a picture that includes a variety of Transformation. e.g. he should be able to modify a picture so that detail appears more clearly or reduce it, so that picture becomes more visible . He should also be able to apply transformation to symbols. It is also useful to change the scale of the symbol and to rotate it at some angle. Two aspects of the formulation of transformation emphasized.

1. A Transformation is a single mathematical entity and as such can be denoted by a single symbol.

2. Two Transformations can be combined or concatenate to yield a single transformation with the same effect as the sequential application of the original tool. Thus Transformation A might be a translation and transformation B a scaling.

The concatenation property allows us to determine a transformation C= AB whose effect is to translate and scale.

The principles of these notation and concatenation will pertain to all transformations describe such as clippings, windowing and 3D perspective transformation. Each of these transformations is used to generate a new point (X, Y) from the coordinates of a point (x, y) in the original picture description.

Translation :- The form of the translation transformation is- x'= x+Tx

y'= y+Ty

Where Tx and Ty are translation parameter. As an example consider a triangle defined by three vertices (20,0) (60,0) (40,100) being translated 100 units to the right and 10 units up.

(2)

Tx= 100, Ty = 10

The new vertices are (120, 10) (160,10) (140,110)

Translation

Rotation : To rotate a point (x, y) through a clock were angle () about the origin of the coordinate system.

We write

X' = x Cos+ y sin y'= x sin + y Cos

(3)

If S

x

and S

y

are not equal, they have the effect of distorting pictures by

elongating or shrinking them along the directions parallel to the coordinate axis.

Example of distortion: for instance fig(a) can be distorted as shown in fig(b) or

fig(c)

(4)

Concatenation: Sequences of transformations can be combined into one transformation by the concatenation processes. These sequences occur frequently in picture definition. It is rare that we want to apply a simple transformation such as rotation about the origin or scaling relative to the origin.

In general we need to perform more complex transformation like rotation about arbitrary points can be performed by applying a sequence of three simple transformations, a translation followed by a rotation followed by another translation. Sequences of transformations also arise when subroutine calls are nested. The ordering of a sequence of transformations must not be destroyed by the concatenation. Consider the following sequence, rotate the triangle with 90˚, then translate it with Tx=-80 and Ty=0, The resulting triangle is :

If the order of the two transformations is reversed, the new figure is shown in

the fig(b).

(5)

The main aim of concatenation is to represent a sequence of transformations as a transformation. The sequence above is :

x’ =x cosƟ +y sinƟ putting Ɵ=90˚

y’= -x sinƟ +y cosƟ 1

st

transformation

x’ = y y’ = - x Followed by

x’’ = x – 80 y’’ = y + 0

the concatenation is simply x’’ = y – 80

y’’ = - x

1

st

transformation Rotation

(20,0) x’ = 0, y’ = - 20

(60,0) x’ = 0, y’ = - 60

(40.100) x’ = 100, y’ = - 40

(6)

2

nd

transformation Translation x’’ = x’ +Tx

y’’ = y’

x’’ = - 80 , -80, 20 y’’ = -20, -60, -40

Or directly from

x’’=y – 80

(7)

y’’= -x

x’’=0 - 80 - 80 x”=0 – 80 x”= 100 – 20 = 20

y”= - 20 – 20 y”= – 60 y”= – 40

(-80.-20) (-80, -60) (20, -40)

Ex: Apply these transformations to a triangle (20,10) (60,20) (40,120).

Rotation 90˚

Scale twice

Translate Tx=40 Ty=20 Soln:

I

st

rotation:

x’ =x cosƟ +y sinƟ y’= -x sinƟ +y cosƟ

x’ = y 10, 20, 120 y’ = - x -20, -60, -40

(10, -20), (20, -60), ( 120, -40) Scaling:

x’’ = x’Sx 2x’ 2y y’’ = y’Sy 2y’ -2x

x’ = y 20, 40, 240 y’ = - x -40, -120, -80 (20, -40), (40, -120), ( 240, -80) Translation:

x”’=x”+Tx=x”+40

(8)

y”’=y”+Ty=y”+20

x”’=20+40=60 (60 , - 20) y”’= -40+20= - 20

x”’=40+40=80 (80 , - 100) y”’=- -120+20= - 100

x”’=240+40=280 (280 , - 60)

y”’=- -80+20= - 60

(9)

Use of concatenated transformation has several advantages. We can represent it more compactly than a sequence and we can generally compute the transformation with fewer arithmetic operations as compared to apply each of the transformation one after the other. However, the rules for concatenating transformation equation are quite complex. They are much simpler if we use matrices to define transformations.

Example:

Apply three transformation to a triangle (20,10) (60,20) (40.120).

i) Scale 3 ii) Rotate 45˚

iii) Translate Tx=60, Ty= -20

Matrix Representation:

Two dimensional transformation can be represented in a uniform way by a 3X3

matrix. The transformation of a point (x, y) to a new point (x’, y’) by means of

(10)

x’ y’ 1 = x y 1 a b 0 b c 0 c f 1

Where, the 3X3 matrix completely specifies transformations. The matrix, a single entity represents the transformation. When we name this matrix we gain the ability to denote the entire transformation by a single name.

Matrix formulation of transformation:

The parameters of the 3X3 transformation matrix can be arranged to make the matrix representation simple. Transformation of translation, rotation and scaling are:

Transformation:

Translation :[x’ y’ 1]=[x y 1 ] 1 0 0 0 1 0 T

x

T

y

1 Rotation : [x’ y’ 1]=[x y 1 ] cosƟ –sinƟ 0

SinƟ cosƟ 0 0 0 1 Scaling[x’ y’ 1]=[x y 1 ] S

x

0 0

0 S

y

0 0 0 1

Concatenation of matrix transformation:

The matrix formulation has the consequence virtue of making the concatenation of transformation sequences particularly straight forward.

Consider the following sequence:

(11)

Scale a point with S

x

=S

y

=2 Translate it t

x

=10, t

y

=0 i)scaling

[x’ y’ 1]=[x y 1] 2 0 0 0 2 0

0 0 1 ………..1 Ii) translation

[x’’ y’’ 1]=[x’ y’ 1] 1 0 0 0 1 0

10 0 1 ………..2

The result [x’ y’ 1] is merely an intermediate one. We can eliminate it by substituting the equation (1) into (2)

[x’’ y’’ 1]=[x’ y’ 1] 1 0 0 0 1 0 10 0 1

[x y 1 ] 2 0 0 1 0 0 0 2 0 0 1 0 0 0 1 10 0 1 [x y 1 ] 2 0 0

0 2 0

(12)

10 0 1

The two 3x3 matrix are Independent of the (x,y) points being transformed and are derived only from the parameters (Sx, Sy, Tx, Ty) specified in transformation equation. We can therefore simplify the equation by multiplying the two 3x3 matrix to yield 3x3 matrix.

Thus the product of two Matrix transformations represents the concatenation of these transforms. Irrespective of the no. of transformation in a sequence, we can always concatenate so that a single 3x3 matrix represent the entire sequence.

Complex transformation can be described as concatenation of simple ones. Suppose we wish to derive a transformation which will rotate the point through a clockwise angle about the point (Rx, Ry). The rotation transformation can be applied to rotate a point only about the origin. Therefor we must first translate point so that (Rx, Ry) becomes the origin.

[x’’ y’’ 1]=[x’ y’ 1] 1 0 0

0 1 0

-Rx -Ry 1

Then the rotation can be applied.

[x’’ y’’ 1]=[x’ y’ 1]

Cos -Sin 0

Sin Cos 0

0 0 1

(13)

and finally we translate the point so that the origin is returned to (Rx, Ry)

[x’’ y’’ 1]=[x’ y’ 1]

1 0 0

0 1 0

Rx Ry 1

If values of (Rx, Ry, ) are known the three Matrix can be multiplied to leave transformation matrix.

Problem :

Translate Tx =10 ,Ty=20 Rotate 450

Scale = 2 = Sx = Sy , the vertices of the triangle are (10,20),(60,20),(80,120).

Apply the above transformations using matrix method.

3D Transformation & Their Matrix Representation :-

Geometric Transformation play an important role in generating images of3D Scenes.

They are used in modelling to express locations of objects relative to other. In generating a view of the scene, they are used to achieve the effect of different viewing positions and direction. Finally, the perspective transformation is used in many 3D- scenes on to a 2 D- screen. In applications where the view point changes rapidly or where objects move relative to each other, transformation must be carried out repeatedly. It is therefore, necessary to find efficient ways of performing 3D Transformation.

(14)

Transformation :- The techniques we shall develop for 3 D . Transformation is Extension of the 2 D techniques. Two Important aspects of the earlier formulation are retained. A Transformation is expressed as a single entity. The transformation matrix, complex transformation, expressed as a sequence of primitive transformation, can be concatenated to yield a single transformation Matrix that has the same effect as the sequence of primitives.

(i) Translation : The Transformation which translate a point (x, y, z) to a new point (x', y', z') is

[x’’ y’’ 1]=[x’ y’ 1]

1 0 0 0

0 1 0 0

0 0 1 0

Tx Ty Tz 1

where Tx, Ty, Tz are the components of translation in the x, y and z directions respectively.

(ii) Rotation:-3 D Rotation transformation have more complexity than 2 D rotation transformation. We must determine a 3 D axis about which to rotate. As in 2D- the simplest form of the transformation occurs when the axis passes through the origin and is aligned wish the coordinate axis. To rotate about an arbitrary point we must concatenate three transformations.

First Translates the point to the origin, the second performs rotation and third translates the origin back.

In 3D, it is helpful to derive the transformation for rotation about each of the 3 coordinate axis

(a) Rotation about the Z- axis through an angle is achieved with the following transformation

(15)

[x’ y’ z’ 1 ]= [x y z 1 ] Cos -Sin 0 0

Sin Cos 0 0

0 0 1 0

0 0 0 1

Matrix representation for figure (a)

The Rotation angle as measured clockwise above the origin when looking at the origin from a point on the + Z axis. Notice that a Transformation matrix affects only the values of x and y coordinates.

(b) Rotation about the coordinate axis

Cos  0 Sin 0

[x’ y’ z’ 1 ]= [x y z 1 ] 0 1 0 0

-Sin 0 Cos 0 0

0 0 0 1

For Figure -B

(c) Rotation about the x- coordinate - axis :

[x’ y’ z’ 1 ]= [x y z 1 ] 1 0 0 0

0 Cos -Sin 0

0 Sin cos 0

0 0 0 1

---for figure (c)

(16)

All these rotation primitives are minor variants of a single schema. Matrix expressing rotation about the x and y axis are obtained from the z-axis rotation matrix by permitting the axis in a cycle fashion.

Scaling: A scaling transformation can be used to scale dimensions in each coordinate direction separately.

[x’ y’ z’ 1 ]= [x y z 1 ] Sx 0 0 0

0 Sy 0 0

0 0 Sz 0

0 0 0 1

Inverse Transformation :-

Many of the Transformation given above are Inverse which performs the symmetrical apposite transformation. The inverse of Translation matrix, which undo the effect of the translation matrix.

[x’ y’ z’ 1 ]= [x y z 1 ] 1 0 0 0

0 1 0 0

0 0 1 0

-Tx -Ty -Tz 1

The Inverse of Equation is

[x’ y’ z’ 1 ]= [x y z 1 ] Cos () -Sin () 0 0 Sin() Cos() 0 0

0 0 1 0

0 0 0 1

(17)

Which is a rotation of same magnitude and about the same axis eq. (a) but in the opposite direction -

We shall denote the Inverse of transformation T by T-1. The two examples suggest the matrix can be obtained by choosing appropriate values for the parameters of the primitive transformation.

Concatenation :- The successive application of a number of Transformation can be achieved with a single transformation matrix, the concatenation of the sequence.

Suppose two transformations T1 and T2 are to be applied successively the same effect can be achieved by the application of a single transformation T3, which is simply the products of the matrix T1 and T2. This can be readily demonstrated, the point (x, y, z) is transformed into (x', y', z') by T1.

[x' y' z' 1]= [x y z 1 ] T1 T1 is transformation matrix.

The point (x'', y'', z'') is then generated by applying T2 [x'', y'', z'',1] = [ x', y', z', 1][T2]

[x'', y'', z'',1] = [ x', y', z', 1] [T1 ] [T2]

[x, y, z, 1] [T1T2]

The order of application of the transformation must be preserved when the transformation matrices are applied together.

Problem: Translate Tx= 10 , Ty = 10 , Ty = 10 , Tz = -20 Scale = 2 units

Rotate (+x-axis ) = 900 (1) Tranaslation :-

(18)

1 0 0 0

0 1 0 0

0 0 1 0

10 10 -20 1

=[x+10, y+10, z-20, 1]

2. Scaling :

[x11, y11, z111]= [x+10 y+10 z=20, 1]

2 0 0 0

0 2 0 0

0 0 2 0

0 0 0 1

= [ 2x+20 2y + 20 2 z-40 1]

(3) Rotation :-

[x111, y111, z1111] = [2x+20 2y+20 2z-40 1]

1 0 0 0

0 Cos -Sin 0

0 Sin Cos 0

0 0 0 1

1 0 0 0

0 0 -1 0

0 1 0 0

0 0 0 1

[x''', y''', z'''1] = [ 2x + 20 2z-40 - 2y – 20 1 ] x''' = 2x + 20

y''' = 2z - 40 z111 = -2x - 20

(19)

X''' Y''' Zx'''

0 -20 -40

60 -20 -40

60 +20 -40

0 +20 -40

0 -20 20

60 -20 20

60 20 20

0 20 20

Rotation about an arbitrary Point: - Let us determine the transformation Matrix for a counter. Clockwise rotation about point (xc , yc)

For this we use three transformations step:

1.Translate the point (Xc, Yc) to origin.

2. Rotate about the origin.

3. Translate the centre of rotation back to (Xc, Yc)

1) Translation: The translation which moves (Xc, Yc) to the origin.

T1= 1 0 0 0 1 0 -Xc -Yc 1

Rotation:

R= Cos Sin 0 -Sin cos 0 0 0 1

Translation: Again translate back and indicate by T2.

(20)

T2= 1 0 0

0 1 0

Xc Yc 1

Then apply and find value of T1RT2.

References

Related documents

• If the condition is true originally, then the value of some variable used in condition must change in the execution of body, so that eventually condition becomes false.. •

produce no compression. So they need to be quantized. • The human eye is not sensitive to changes in the higher frequency content. So we can have cruder quantization for the

cbna CS766: Analysis of concurrent programs (first half) 2021 Instructor: Ashutosh Gupta IITB, India 1.. CS766: Analysis of concurrent programs (first

function is defined at a fixed set of sample points on the shape. Levy

The Macroeconomic Policy and Financing for Development Division of ESCAP is undertaking an evaluation of this publication, A Review of Access to Finance by Micro, Small and Medium

motivations, but must balance the multiple conflicting policies and regulations for both fossil fuels and renewables 87 ... In order to assess progress on just transition, we put

These gains in crop production are unprecedented which is why 5 million small farmers in India in 2008 elected to plant 7.6 million hectares of Bt cotton which

At the center of this aerial view of spring in Yellowstone National Park, water temperatures reach near 88°C which is too hot to support most life — but along the edges of the