Você está na página 1de 7

LOVELY PROFESSIONAL UNIVERSITY

HOME WORK: #2

Course No: CSE405 Course Title: COMPUTER GRAPHICS

School: LST Department: CSE/IT

Submitted to:ms. Taranpreet Kaur

Rollno:B42 Section:C1803 Batch: 2008

Regno: 10803435

Max. Marks: 7 DOA:7/2/2011 DOS:23/2/2011

1.

what do you understand by composite transformation .perform a general fixed point scaling with an
example.
Ans: A composite transformation matrix is a product of two individual transformation matrices.
This method of multiplying two matrix is also called concatenation.Through this method we can set
up a matrix for any sequence of transformations .This is basically done by finding out the product of
individual transformations.

If two successive transformations are applied to a coordinate position P

where

General fixed point scaling:

This is generally a transformation sequence to produce scaling with respect to a


selected fixed point (xf, yf) using a scaling function that can only scale relative to
the coordinate origin.

1. Translate object so that the fixed point coincides with the coordinate origin

2. Scale the object with respect to the coordinate origin


3. Use the inverse translation of step 1 to return the object to its original position

Concatenating the matrices for these three operations produces the required scaling matrix.

2.

Prove that if two successive translation vectors T1(4, -2) and T2(-3, 5) are applied to an object then the
output will equivalent to the single additive translation by T3(1, 3).
Ans :

Let p be the required point after successive translation is carried out on T1(4, -2) and T2(-3, 5) :

we have T1(4,-2) and T2(-3, 5) :

composite transformation matrix for the given sequence T1(4, -2) and T2(-3, 5) is give by product of
the two individual transformations

hence, we have
T1(4, -2) .T2(-3, 5)=T(4-3,-2+5)

=T(1,3).which is single additive translation by T(1,3)

3.Derive the transformation that rotates an object point Q(x,y), degree about a fixed center of rotation
P(h,k).

Ans

We know ,

the transformed coordinates in terms of angles Ѳ and ф as:

We replace and

rotation matrix is given by :

R=
:

4. Scale a triangle bounded by A(30, 10), B(20, 30) and C(10, 20) to double its height and half its
width.

Ans:

We have,

Since the triangle is scaled to double its height and half its width ,we have scaling factor in the x
direction to be ½ and in the y direction it is 2 .

In other words: Sx =1/2 and Sy = 2.

We know :

X’=X*Sx

Y’=Y*Sy

Point A(10,10):

(X,Y) = (10,10)

X’=10*(1/2)

X’=5

Y’= 10*2 = 20

Now point A is scaled to A’=(5,20)

Point B(20,10):

X’=20*(1/2) = 10

Y’=10*2 = 20

Now point B is scaled B’=(10,20)

Point C(10,20):

X’=10*(1/2) =5

Y’=20*2 = 40

Now point C is scaled to C’=(5,40)

Therefore the reqd points are given by :

A’= (5, 20)


B’= (10, 20) C’= (5, 40)

5.

Write a PseudoCode procedure to implement the boundary fill algorithm in the


text in its basic form, using the 4-connected definition for region pixels and also
discuss the disadvantage of boundary fill technique over flood fill technique

Ans >>

The boundary fill algorithm fills a region with the given fill color until the given boundary
color is found. We can have either 8 point or 4-point technique to color a region. The
procedure uses a recurssive function. The function return when the pixel to be colored is the
boundary color or is already the fill color.

Pseudo code for the algorithm:

Boundary Fill Algorithm:


a. Choose a specific interior point [x,y]
b. Use a 4-connected approach to visualize the functionality of the algorithm
c. Possibility to change orientation of algorithm
d. Possibility to change color of the background and filling color.

The boundary-fill method requires the coordinates of a starting point, a fill color, and a
boundary color as arguments.

The Boundary fill algorithm performs the following steps:

1, Check the pixel for boundary color ̇

2.Check the pixel for fill color ̇

3.Set the pixel in fill color ̇

4.Run the process for neighbors

The pseudo code for Boundary fill algorithm can be written as:

boundaryFill (x, y, fillColor , boundaryColor)

if ((x < 0) || (x >= width)) return if ((y < 0) || (y >= height))

return current = GetPixel(x, y) if ((current != boundaryColor) && (current != fillColor))


setPixel(fillColor, x, y)
//use a 4 connected approach

boundaryFill (x+1, y, fillColor, boundaryColor)

boundaryFill (x, y+1, fillColor, boundaryColor)

boundaryFill (x-1, y, fillColor, boundaryColor)

boundaryFill (x, y-1, fillColor, boundaryColor)

6. Generate the homogeneous matrix for the composite transformation by applying the translation
(tx,ty), followed by uniform scaling (s), and then followed by rotation (θ), on the object (x,y) in a 2D
homogeneous coordinate system. Further, apply the transformation taking x=5, y=3, tx=7, ty=3, s=2,
and θ=-30.

Ans:

Here ,we are required to first apply translation and then scaling and then we need to rotate by
angle θ .hence the reqd matrix will be a composite matrix .

The reqd homogeneous matrix for the composite transformation will be the product of four
matrices and is given by

Here , we have :

X’ cos -sin 0 s 0 0 1 0 tx X

Y’ = sin cos 0 0 s 0 0 1 ty Y

1 0 0 1 0 0 1 0 0 1 1

cos -sin 0 s 0 s*tx X

= sin cos 0 0 s s*ty Y

0 0 1 0 0 1 1
s.cos -s.sin s.tx.cos -s.ty.sin X

= sin s.cos s.tx.sin +s.ty.sin Y

0 0 1 1

Hence , reqd matrix is :

X’ s.cos .X - sin .Y + s.tx.cos - s.ty.sin

Y’ = s.sin .X + s.cos .Y + s.ty.sin + s.ty.cos

1 1

X’ 2.cos150 – sin90 + 14cos30 - 6sin30

Y’ = 2.sin150 + 2.cos90 +6sin30+ 6cos30

1 1

Você também pode gostar