Reputation: 664
How to find the decision parameter for drawing different functions like parabola, sine curve, bell curve? Please tell me about the approach why do we sometimes multiply by constant? For Example
why not only take (d1 -d2) as parameter
Upvotes: 1
Views: 1160
Reputation: 153367
Bresenham's algorithm as stated by the OP is a bit amiss, but I assume the following.
The decision parameter could adjust d1 - d2
and not scale by some constant as you suggest were it not for the initialization of the decision parameter. It is not generally scalable by that constant.
// code from http://en.wikipedia.org/wiki/Bresenham's_line_algorithm
plotLine(x0,y0, x1,y1)
dx=x1-x0
dy=y1-y0
D = 2*dy - dx // Not scalable by 2
plot(x0,y0)
y=y0
for x from x0+1 to x1
if D > 0
y = y+1
plot(x,y)
D = D + (2*dy-2*dx) // Scalable by 2
else
plot(x,y)
D = D + (2*dy) // Scalable by 2
Upvotes: 1