Assignment 2
Assignment 2
Section B1802
2b.
.
3. Use the formulas above to iterate pxk+1 until b2x>a2y. 4. Rename the current (xk,yk) as (x0,y0) and calculate the initial decision parameter value in the
2nd region: .
5. Use the formulas above to iterate pyk+1 until y <= 0.
6. For both regions plot the other three symmetry points. 7 Shift to center at h, k.
Ques2- Draw the circle with pixel as (30,50) respect to origin (0, 0) where radius of circle is 25..
Solution:Selected pixel positions (solidcircles) along a circle path withradius r = 25 centered on
the origin, using the midpoint circle algorithm.Open circles show the symmetry positions in the first quadrant with the given pixel (30,50)
return current = GetPixel(x, y) if ((current != boundaryColor) && (current != fillColor)) setPixel(fillColor, x, y) boundaryFill (x+1, y, fillColor, boundaryColor) boundaryFill (x, y+1, fillColor, boundaryColor) boundaryFill (x-1, y, fillColor, boundaryColor) boundaryFill (x, y-1, fillColor, boundaryColor)
Ques4 Give the rules for scan conversion of polygon region with the help of a example
Ans: The job of scan conversion is to shade pixels lying within a closed polygon, and to do so efficiently. The fill colour will in general depend on the lighting, texture, and visibility of the polygon being scan-converted. These will be ignored for the time being. Let's assume that the polygon is closed and has ordered edges.
intersect each scanline with all edges sort intersections in x calculate parity of intersections to determine in/out
There are many ways to draw polygons. All have their uses. Some are fast, others very slow. The most popular method, used in practically every game, rendering engine, and graphics package which handles polygons, is known as scan converting. (i)This method uses only integer maths, takes up very little memory, and is simple to understand. The algorithm can be adapted to handle flat or gourad shaded, textured and bump mapped polygons. (ii)It is an approximate method. You will never be able to draw a totally perfect polygon with smooth edges on a normal screen, because of the fact that the picture is divided up into pixels. It is possible to make the edges look better, but the edges will nevertheless look jaggy.
On a pixelated screen, a small polygon like this will end up with nasty edges when viewed close up. (iii)The method works by taking the polygon a line at a time, processing all the edges, then filling in the surface. If you haven't already, take a look at the page about drawing lines. You will find this very helpful. (iv)A single scan conversion is the process of converting a polygon edge into data which can be used by the polygon filling routine. The process is essentially a single case of the line drawing algorithm. A polygon edge is calculated as if it were a line, but the line is not drawn to the screen. Instead the information is saved in a buffer for use later. So the line algorithm travels down an edge, calculating the X-coordinate of the pixel which lies closest to the line for each Y-coordinate.
Ques5:Find the transformation that scales (with respect to origin) by a) a units in the X direction, Ans:In this translation transformation is used in the X direction A translation is applied to an
object by repositioning it along a straight-line pathfrom one coordinate location to another
b) b units in the Y direction, Ans: In this scaling transformation is used in the X direction c)simultaneously a units in the X direction and b units in the Y direction Ans: In This Shearing transformation is used in the X direction and b units in the Y direction
Ques6
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
Solution: A general
Y = RSyx 1 0
Sx cos Sx sin 0
x=6, y=4, tx=8, ty=4, s=3, and =-30. T (Tx,Ty). R(Xc,Yc, ). S(Xc,Yc,Sx,Sy)
Sx cos 30 Sx sin 30 0
These unit vectors are transformed by the rotatign submatrix, Rxx,Rxy,) is converted to a unit vector along the x axis and (Ryx, Ryy) is transformed
T(tx,ty).R(x,y,) cos sin 0 -sin cos 0 x(1- cos +y sin + tx) y(1- cos 1 -x sin + ty )
T(8,4).R(6,4,-30)
Here, orthogonal unit vectors in the upper-left 2-by-2 submatrix are cos ,- sin
sin , cos and cos , 0 cos sin , = 1 1 1 0 1
sin , cos 0 0 0
0 0
1 = 0