# 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

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

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

z )−( 2.3). 4) c = ( c 1 . 2.3 ) ]=0 ( x−2 ) + ( y−2 ) −2 ( z−3 )=0 . a.2. b3 - a3 ) = (1.−2 ) ∙ [ ( x . -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.2. 1. a3 ) = (2.2. c3 ) = (3.1. (3. c2 - b2 . 1. y . What is an equation for the plane that this triangle lies in? A= (2.3). 3) b = ( b1 . 2) x -1 = (1. 3. -2) b.1. b3 ) = (3. b2 .3 ) ]=0 ( 1.3. 1) v bc = ( c1 - b1 .3) (3. ⃗n =(1. What is the normal vector to this triangle? a = ( a1 . a2 . c 2 . b2 - a2 .Question 2 Consider a triangle with corners at (2. 3) v ab = ( b2 - a1 . -1. 1.2.1. -2.−2) ⃗n [ ( x . z )− ( 2. y .4). c3 - b3 ) = (0.

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

. 81) = (13. 130) / (14.5) / (10 . 130) c.5 . What is the disadvantage of Liang-Barsky algorithm to Cohen Sutherland line clipping algorithm The Liang-Barsky algorithm is more efficient than Cohen Sutherland. 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. 80.= (10.

Sign up to vote on this title