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

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

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

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

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

Sign up to vote on this title
UsefulNot useful

Master Your Semester with Scribd & The New York Times

Special offer for students: Only $4.99/month.

Master Your Semester with a Special Offer from Scribd & The New York Times

Cancel anytime.