Consider the midpoint (or Bresenham) algorithm for rasterizing lines given below:
- Input $(x_1, y_1)$ and $(x_2, y_2)$
- $y=y_1$
- $d=f(x_1+1, y_1+1/2)$ //f is the implicit form of a line
- for $x=x_1$ to $x_2$
- do
- plot$(x,y)$
- if $(d<0)$
- then
- $y=y+1$
- $d=d+(y_1-y_2)+(x_2-x_1)$
- else
- $d=d+(y_1-y_2)$
- end
- 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:
- P only
- P and Q only
- Q and R only
- P, Q and R