Fixing Line Algorithm

∆X ∆Y

0 ≤ m ≤ 1

2

3

7

6

4

5 8

1

∆X ∆Y

1 < m < ∞

∆X ∆Y

1 < m < ∞

∆X ∆Y

0 ≤ m ≤ 1

∆X ∆Y

0 ≤ m ≤ 1

∆X ∆Y

1< m < ∞

∆X ∆Y

1< m < ∞

∆X ∆Y

0 ≤ m ≤ 1

negative positive

∆X: x2

< x1 : change the orientation

swap starting and ending points:

x2

with x1

, y2

with y1,

∆X = abs(∆X)

This will cause the ∆X to become ∆X, 1st condition.

1 < m < ∞: make it 0 ≤ m ≤ 1

Invert the coordinates:

x2

with y2

, x1

with y1,

Store original m, because remembering it was > 1, will

help swapping back the pixels when they are drawn

This will cause the placement of the points to

represent a line with the slope in the acceptable

range, fulﬁlling the 3rd condition

Octant conversions: 3 to 7, 4 to 8, 5 to 1, 6 to 2

Octant conversions: 2 to 1

m: calculate with original, unchanged ∆Y and ∆X

and never recalculate it again, leave as it is here

∆Y: ∆Y = abs(∆Y)

This will cause the ∆Y to become ∆Y, 2nd condition.

Octant conversions: 7 to 2, 8 to 1

Now all lines are as in the 1st octant.