Bit-Rate
December 26, 2024Computer-Graphics
December 26, 2024Bresenham’s-Algorithm
Question 5 |
Consider the midpoint (or Bresenham) algorithm for rasterizing lines given below :
(1) Input (x 1 ,y 1 ) and (x 2 ,y 2 )
(2) y=y 1
(3) d=f(x 1 +1, y 1 +1⁄2) // f is the implicit form of a line
(4) for x=x 1 to x 2
(5) do
(6) plot(x,y)
(7) if(d<0)
(8) then
(9) y=y+1
(10) d=d+(y 1 – y 2 ) + (x 2 – x 1 )
(11) else
(12) d=d+(y 1 – y 2 )
(13) end
(14) end
Which statements are true ?
P: For a line with slope m>1, we should change the outer loop in line (4) to be over y.
Q: Lines (10) and (12) update the decision variable d through an incremental evaluation of the line equation f.
R: The algorithm fails if d is ever 0.
(1) Input (x 1 ,y 1 ) and (x 2 ,y 2 )
(2) y=y 1
(3) d=f(x 1 +1, y 1 +1⁄2) // f is the implicit form of a line
(4) for x=x 1 to x 2
(5) do
(6) plot(x,y)
(7) if(d<0)
(8) then
(9) y=y+1
(10) d=d+(y 1 – y 2 ) + (x 2 – x 1 )
(11) else
(12) d=d+(y 1 – y 2 )
(13) end
(14) end
Which statements are true ?
P: For a line with slope m>1, we should change the outer loop in line (4) to be over y.
Q: Lines (10) and (12) update the decision variable d through an incremental evaluation of the line equation f.
R: The algorithm fails if d is ever 0.
Q and R only | |
P only | |
P and Q only | |
P,Q and R |
Question 5 Explanation:
From the code given in question gives information that the algorithm will work if d is ever 0, So the statement R is false.
Line 10 and 12 will update the value of d , So the statement Q is true.
Line 10 and 12 will update the value of d , So the statement Q is true.
Correct Answer: C
Question 5 Explanation:
From the code given in question gives information that the algorithm will work if d is ever 0, So the statement R is false.
Line 10 and 12 will update the value of d , So the statement Q is true.
Line 10 and 12 will update the value of d , So the statement Q is true.