Mid-Point Line Plotting Algorithm: Made By: Dimpy CHUGH (1833) Drishti Bhalla (1838)
Mid-Point Line Plotting Algorithm: Made By: Dimpy CHUGH (1833) Drishti Bhalla (1838)
PLOTTING ALGORITHM
ADVANTAGES
It chooses the pixels closest to the line with accuracy, consistency
and straightness.
It is very simple and requires only integer data and simple
arithmetic.
It avoids division and multiplication and thus avoid truncate
errors.
BASIS OF ALGORITHM
Given the previous pixel P, there are two candidates for the next pixel
closest to the line, E and NE .
If the M is above the line, choose E. If M is below the line, choose NE.
10) else
11) d=d+dx-dy
12) x=x+1
13) Plot(x,y)
EXAMPLE Draw a line from (4,8) to (9,12)
and plot the points accordingly.
Initially:
(x,y)=(4,8)
(x1,y1)=(9,12)
dy=(y1-y0)= (12-8)= 4
dx= (x1-x0)=(9-4)= 5
Now, the first decision variable
(d0)= dy- dx/2
= 4-5/2
= 1.5