in Unknown Category edited by
3,471 views
0 votes
0 votes

​​​​​​​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 over $0$

Choose the correct answer from the code given below:

  1. P only
  2. P and Q only
  3. Q and R only
  4. P, Q and R
in Unknown Category edited by
by
3.5k views

Please log in or register to answer this question.

Related questions