You are on page 1of 10

Annexture II

Homework Title/No. : 3 Course Code :cse 405

Course Instructor : lect. NITIKA SHARMA Course Tutor(if applicable)


:_________

Date of Allotment :_________________ Date of submission :6-APR-2011__

Student’s Roll No. :_RC1801A10 ____ Section No. :C1801___

Declaration :

I declare that this assignment is my individual work. I have not copied from any
other student’s work or from any other source except where due
acknowledgement is made explicitly in the text,nor has any part been written for
me by another person.

Student’s Signature :Amber

Evaluator’s comments :

________________________________________________________________
___________

Marks obtained :______________________ out of


_________________________
Q.1.How can scaling with respect to a point P0(.x0,y0,z0) be defined in terms
of scaling with respect to the origin?

Ans the matrix expression for scaling transformation of a position p=(x0,y0,z0)


relative to the coordinate origin can be written as

X’ sx 0 0 0 x0
Y’ 0 sy 0 0 y0
Z’ = 0 0 sz 0 z0
1 0 0 0 1 1

P’=s.p
Where scaling parameters sx,sy,sz are assigned any positive values.
X’=x.sx
Y’=y.sy
Z’=z.sz
Scaling an object with transformation changes the size of object and repositions
the object relative to coordinate origin. Also if the transformations parameters
are not all equal,relative dimentions in the object are changed.we preserve the
original shape of the object with a uniform scaling(sx=sy=sz).

Scaling about a fixed point P0(.x0,y0,z0) can be accomplished by the following:

1. Translating P0 to the origin


2. Scaling the object
3. Translating P0 back to original position.

Q 2 Develop a text clipping algorithm that clips individual characters


assuming that the characters are defined in a pixel grid of a specified size..
Ans:

With regard to the representation of characters, we can split clipping into area
clipping or line clipping. Area clipping is used in the case where characters are
represented by a bitmap, and line clipping is practical if characters are
represented by lines. But, in the majority of cases we use characters composed
from lines and curves, so-called vectors. Its advantage is that we can zoom or
scale, without a loss of quality.
According to how precise we want the clipping of a text, we categorize clipping
a text as follows:

• precise clipping
• clipping to a character
• clippinga text by words or whole row.

In normal text coding, each character is represented by one value totaling 1 byte.
In clipping, we should look at a character as an inseparable object. Every
character comprises a minimum rectangle, which we will call a 'character
envelope'. While clipping a character to a character, we test whether the center
of an envelope is in the display box, or whether the envelope is wholly inside the
display box or not. On the basis of this we decide whether to display the given
character.

Q3 Find the transformation which aligns vector V=I+J+K with the vector
N=2I-J-K.
Ans: The transformation which aligns vector V=I+J+K with the vector N=2I-J-
K
√ 6/ √ 3 - 1/√ 3√ 6 -1/√ 3√ 6 0
0 1/√ 6 -1/√ 6 0
1/√ 3 1/√ 3 1/√ 3 0
1 0 0 1

v= i+j+k so,
| v |= √ 12 + 12 + 12 = √ 3
And N = 2i –j-k
so, |N|= √ 22 + (-12) +(- 12)= √ 4+1+1=√ 6

Part b

Q.4. Obtain the rotation matrices about x-axis,y-axis and z-axis in 3D.
Z-Axis Rotation

Z-axis rotation is identical to the 2D case:

x' = x*cos q - y*sin q


y' = x*sin q + y*cos q
z' = z

( cos q sin q 0 0)
Rz (q) = (-sin q cos q 0 0)
(0 0 1 0)
(0 0 0 1)

X-Axis Rotation

X-axis rotation looks like Z-axis rotation if replace:

X axis with Y axis


Y axis with Z axis
Z axis with X axis
So we do the same replacement in the equations:

y' = y*cos q - z*sin q


z' = y*sin q + z*cos q
x' = x

(1 0 0 0)
Rx(q) = (0 cos q sin q 0)
(0 -sin q cos q 0)
(0 0 0 1)

Y-axis rotation looks like Z-axis rotation if replace:

X axis with Z axis


Y axis with X axis
Zaxis with Y axis
So we do the same replacement in equations :

z' = z*cos q - x*sin q


x' = z*sin q + x*cos q
y' = y

(cos q 0 -sin q 0)
Ry(q) = (0 1 0 0)
(sin q 0 cos q 0)
(0 0 0 1)

Q.5. Derive the window to viewport transformation equations by first


scaling the window to the size of the viewport and then translating the
scaled window to the viewport position..

Ans: The computational cost of computing a bounding volume for an object, the
cost of updating it in applications in which the objects can move or change
shape or size, the cost of determining intersections, and the desired precision of
the intersection test. The precision of the intersection test is related to the
amount of space within the bounding volume not associated with the bounded
object.
The purpose of 3D clipping is to identify and save all surface segments within
the view volume fordisplay on the output device. All parts of objects
that are outside the view volume are discarded.
The window to view port transformation equations are:-
xv = xv min +(xw-xw min )sx
yv=yv min +( yw- yw min ) sy

where the scaling factors are


sx= xv max - xv min / xw max -xw min
sy=yv max - yv min / yw max - yw min
following steps are:-

1. Translate world-coordinate window to the origin of the world coordinate system.


2. Rescale the window to the size
3. Translate the viewport to its position on the screen in the device coordinate system.

Then transformation matrix is a

Ssx,sy = Tv. Ssx,sy = *

By multiplication two matrixes, we get

Thus the computing time is saved. A finite view volume is obtained by limiting
the extent of the volume in the zv direction.this is done by specifying the
positions for one or two additional boundary planes.these zv boundary plane are
reffered to as front plane and back plane.front and back clipping allows us to
eliminate parts of the scene that we would like to view and exclude objects that
are in front or of behind the part that we want to look at.also in a perspective
projection we can use the front clipping plane to take out the large projects close
to the view plane that can project into unrecognizable sections with in a view
window.similarly back clipping planes can be used to cut out objects far from
the projection reference reference point that can project to small blots on the
output device.the front and back planes can be in any position relative to the
view plane as long as the projection reference point is not in between the front
and back planes.

Various clipping strategies in 3 dimentional


Point clipping:
Remove points outside window.

A point is either entirely inside the region or not.

Line clipping:
Remove portion of line segment outside window.

• Line segments can straddle the region boundary.

Polygon clipping

the most common case in 3D clipping is that we are clipping graphics objects
made up of polygons. we first try to eliminate the entire object using its
bounding volume Next we perform clipping on the individual polygons using
the Sutherland-Hodgman algorithm.

Rasterization

the most basic rasterization algorithm takes a 3D scene, described as polygons,


and renders it onto a 2D surface, usually a computer monitor. Polygons are
themselves represented as collections of triangles. Triangles are represented by 3
vertices in 3D-space. At a very basic level, rasterizers simply take a stream of
vertices, transform them into corresponding 2-dimensional points on the
viewer’s monitor and fill in the transformed 2-dimensional triangles as
appropriate.

The main transformations are translation, scaling, rotation, and projection. A 3


dimensional vertex may be transformed by augmenting an extra variable (known
as a "homogeneous variable") and left multiplying the resulting 4-component
vertex by a 4 x 4 transformation matrix.
A translation is simply the movement of a point from its original location to
another location in 3-space by a constant offset. Translations can be represented
by the following matrix:

X, Y, and Z are the offsets in the 3 dimensions, respectively.


A scaling transformation is performed by multiplying the position of a
vertex by a scalar value. This has the effect of scaling a vertex with respect
to the origin. Scaling can be represented by the following matrix:

X, Y, and Z are the values by which each of the 3-dimensions are


multiplied. Asymmetric scaling can be accomplished by varying the
values of X, Y, and Z.
Rotation matrices depend on the axis around which a point is to be
rotated.
Rotation about the X-axis:

Q.6. Devise an algorithm for Weiler-Atherton polygon clipping, where the


clipping window can be any specified polygon.

Ans: An algorithm for Weiler-Atherton polygon clipping, where the clipping


window can be any specified polygon :

• Start at an entering intersection


• Follow the edges of the polygon being clipped until an existing
intersection is encountered
• Turn right at the exiting intersection and following clip window edge until
intersection is found
• Turn right and follow the subject polygon
• Continue until vertex already visited is reached
A clipping plane can be defined by a point p on the plane and a unit length
normal n, (we will choose n so that it points towards the inside of the view
volume).
To test if a triangle’s verts are inside or outside of the clipping plane,we
compute a signed distance to the plane for each of the 3 vertices, v0, v1, and v2
d0=(v0-p). n
d1=(v1-p) .n
d2=(v2-p) . n

operation to polygon clipping, working with the line segments that form the
edges
of a polygon.The most common application of 3-D clipping is as part of the
process of hidden
surface removal.

You might also like