Bresenham Line Drawing Algorithm
Bresenham Line Drawing Algorithm
Bresenham
Line Drawing
Algorithm
Procedure-
Given-
ΔX = Xn – X0
ΔY =Yn – Y0
Step-02:
Suppose the current point is (Xk, Yk) and the next point is (Xk+1, Yk+1).
Step-01:
Step-03:
Thus,
•Pk+1 = Pk + 2ΔY – 2ΔX = 3 + (2 x 4) – (2 x 5) = 1
•Xk+1 = Xk + 1 = 9 + 1 = 10
•Yk+1 = Yk + 1 = 18 + 1 = 19
Similarly, Step-03 is executed until the end point is reached or number of iterations equals to 4 times.
(Number of iterations = ΔX – 1 = 5 – 1 = 4)
Problem-02:
Calculate the points between the starting coordinates (20, 10) and ending
coordinates (30, 18).
Solution-
Given-
•Starting coordinates = (X0, Y0) = (20, 10)
•Ending coordinates = (Xn, Yn) = (30, 18)
Step-01:
Step-03:
Thus,
•Pk+1 = Pk + 2ΔY – 2ΔX = 6 + (2 x 8) – (2 x 10) = 2
•Xk+1 = Xk + 1 = 20 + 1 = 21
•Yk+1 = Yk + 1 = 10 + 1 = 11
Similarly, Step-03 is executed until the end point is reached or number of iterations equals to 9 times.
(Number of iterations = ΔX – 1 = 10 – 1 = 9)