CSIT_Labs

Scan Conversion Algorithm

Given coordinate of two points A(x1, y1) and B(x2, y2). The task to find all the intermediate points required for drawing line AB on the computer screen of pixels. Note that every pixel has integer coordinates.

Below are some assumptions to keep algorithm simple.



Table to check the next point from previous | <p align="center">When m < 1</p> | <p align="center">When m > 1 </p> | | ——————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————- | ————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————— | | <p align="center">Po = 2dy-dx </p> | <p align="center">Po = 2dx-dy </p> | | <table><tr><td>When P < 0</td><td>When P >= 0</td></tr><tr><td>xi+1 = xi + 1</td><td>xi+1 = xi + 1</td></tr><tr><td>yi+1 = yi</td><td>yi+1 = yi + 1</td></tr><tr><td>Pi+1 = Pi + 2dy</td><td>Pi+1 = Pi + 2dy - 2dx</td></tr></table> | <table><tr><td>When P < 0</td><td>When P >= 0</td></tr><tr><td>xi+1 = xi</td><td>xi+1 = xi + 1</td></tr><tr><td>yi+1 = yi + 1</td><td>yi+1 = yi+1</td></tr><tr><td>Pi+1 = Pi + 2dx</td><td>Pi+1 = Pi + 2dx - 2dy</td></tr></table> |