Written Assignment 2

NAME: Saiful Emran Bin Abdul Muttalib
MATRIC NO: 46000
Question 1
Explain how you would adapt the rasterisation algorithm you have learned
in the lecture that discretises lines to discretely represent the boundary of
a circle. What pixels would be filled in to represent a circle centered at
(20, 20) with a radius of 5?

The boundary of a circle can be represented discretely by using few methods and
algorithms, namely the Middle Point Circle Algorithm and Bresenham’s Algorithm. In
both algorithm, it takes advantage of the symmetry of a circle; the shape of the
circle is similar in each quadrant. Therefore, computation can be reduced as we only
calculate the pixel position for the first quadrant. The second quadrant can be
obtained by noting that the two circle sections are symmetric with respect to the y
axis. Circle sections of the third and forth quadrant can be obtained from sections in
the first and second quadrants by considering the symmetry about the x axis.

By using Middle Point Circle Algorithm, we determine the closest pixel position
to the specified circle path at each step. For a given radius, r = 5, and the circle

center position,

x
20,2
(¿ ¿ c , y c )=¿ 0), firstly we obtain the first point on the
¿

circumference of the circle centered on the origin as

x
¿
o
¿ o , y¿
¿
¿

Next, we calculate the initial value of the decision parameter by using,

Po=1−r

(for r is an integer)

Initial increment terms for calculating the decision parameters are

the next point along the circle is x ¿ k ¿ ¿ and. if pk >0 the next point along the pk+1 =p k +2 x k +1+1−2 y k+1 where 2 x k +1=2 x k +2 and 2 y k+1=2 y k +2 Then. y ) ¿ onto the circular path centered on the . we determine symmetry points in the other seven half-quadrants. y= y + y c x (¿ ¿ c . we perform the test using the decision parameter. we move each calculated pixel position circle center position x=x+ x c . 2 y o=50 At each xk position starting at k=0. If pk <0 .2 x o =40 . Coordinate values can be plotted by. . pk+1 =p k + 2 x k +1+1 Otherwise. Next. y c ) ¿ x (¿ ¿ .

23) . This steps are taken until value of x≥ y .yk+1 (21. K 0 1 2 Xk+1.24) (23.25) (22.The decision parameter test is done to plot another coordinate values.

-2.3).1. 1.1.Question 2 Consider a triangle with corners at (2. c 2 . 1) v bc = ( c1 - b1 .−2 ) ∙ [ ( x .3). What is an equation for the plane that this triangle lies in? A= (2. y . 4) c = ( c 1 .4). -2) b. -1) a3 b2 Cross product v bc x v pa = a2 b3 - v pb = a3 b1 - v pc = a1 b3 - ∴ v ab v bc x v ab a1 b3 = (-2)(1) – (-1)(1) = -1 = (-1)(1) – (0)(1) = -1 a2 b1 = s(0)(1) – (-2)(1) = 2 = (-1. c3 - b3 ) = (0. b2 . b3 - a3 ) = (1. z )−( 2. 1.3. 3) v ab = ( b2 - a1 . a. 3. a3 ) = (2.1. 3) b = ( b1 .2.−2) ⃗n [ ( x . What is the normal vector to this triangle? a = ( a1 . 2) x -1 = (1. -1. 2. y . b2 - a2 .3) (3. c3 ) = (3. (3.2.2.2. ⃗n =(1. b3 ) = (3.3 ) ]=0 ( 1.3 ) ]=0 ( x−2 ) + ( y−2 ) −2 ( z−3 )=0 . z )− ( 2. 1. a2 . c2 - b2 .

13 0) (- (202. What are the coordinates of the new endpoints of the visible segment? (42. ) + t2( . ) = ( .20) (10. consider the following line which we need to clip on a rectangular viewport with the corner coordinates as [(10. 17) and (42.2 Endpoint visible segment m1 = x 1+ x 2 m2 = y1+y 2 2 2 = −15+ 42 2 = 13. (202. 144). What is the parametric equation of the line? Write it in the form ( . -20). 130)]. ) = ( .144 ) (202. ) + t1( . The endpoints of the line are of coordinates (-15.5 = 17+ 144 2 = 80.5 .Question 3 Based on the Liang-Barsky line clipping algorithm.13 0) (10. a. ) t1 and t2 values are the approximation ratios range within [0. ) Where and ( . 1] ( x ) = ( -15 ) + t1 ( 27 ) ( y ) = ( 42 ) + t2 ( 161 ) b.

5) / (10 .5 . . 130) c. 130) / (14.= (10. 80. What is the disadvantage of Liang-Barsky algorithm to Cohen Sutherland line clipping algorithm The Liang-Barsky algorithm is more efficient than Cohen Sutherland. 81) = (13. but Cohen Sutherland does trivial accepts and rejects more faster so it should be considered instead if most of the lines needed to clip would be completely in or out the window.

Master your semester with Scribd & The New York Times

Special offer for students: Only $4.99/month.

Master your semester with Scribd & The New York Times

Cancel anytime.