This algorithm is implemented using Python with the help of Matplotlib library for graph plotting.
What we do?
- We check how much we move up and across for each step.
- If dy < dx, we mainly move across.
- But if dy becomes bigger than dx, we adjust by moving up a bit.
Why we do it?
By doing this, we ensure that our line remains straight and stays close to the ideal slope ( m ) (closer to horizontal) without missing any points.
Input: Case: (1,1), (8,4)
What we do?
- We check how much we move up and across for each step.
- If dy > dx, we mainly move up.
- But if dx becomes bigger than dy, we adjust by moving across a bit.
Why we do it?
By doing this, we ensure that our line remains straight and stays close to the ideal slope ( m ) (closer to vertical) without missing any points.
Inputs: Case: (1,1), (4,8)
Why we didn't apply case 1 for the line between (1,1) and (4,8)?
If we used Case 1 (0 < m < 1) for the line between (1,1) and (4,8), it would look like we're climbing a hill with tiny steps when we actually need big steps. The line would appear too flat compared to the steepness we want between these two points. So, we adjusted the algorithm to prioritize changes in the x-coordinate. This ensures that the line rises steeply, matching the steeper slope. We also iterated over y-coordinates and calculated corresponding x-coordinates.