Tutorial
Line and Curve Drawing

  1. No. It is not the same as the midpoint algorithm because it can set two pixels in the same column, as shown below. It could be made equivalent by making the height of the rectangle always one unit, irrespective of the line angle.

  2. [ There may still be mistakes in the following solution -- let me know] Let's work only with the portion of the parabola having slope 0 <= m <= 1.
    First, let k = a/b, where a and b are integers.
    
    F(x,y) = a(x-x0)^2 - b(y-y0)
         d = F(x+1,y+0.5)
    if d<0
       midpoint is above line
       go E
    
       d_new = F(x+2, y+0.5)
       delta_d = d_new - d = F(x+2, y+0.5) - F(x+1, y+0.5)
               = a (2*x + 3 - 2*x0)
    if d>0
       midpoint is below line
       go NE
    
       d_new = F(x+2, y+1.5)
       delta_d = d_new - d = F(x+2, y+1.5) - F(x+1, y+0.5)
               = a (2*x + 3 - 2*x0) - b
    
    d_start = F(x0 +1, y0+0.5)
            = a - 0.5*b
    
    Let d' = 2*d to make the algorithm all integer
    
    Final algorithm
    
    d = 2*a - b
    x = x0
    y = y0
    while (slope<=1)
      setpixel(x,y,colour)
      tmp = 2*a*(2*x + 3 - 2*x0)
      if (d>0) {         /* go NE */
        d = d + tmp - 2*b
        y = y + 1
      } else {
        d = d + tmp
      }
      x = x + 1
    }