Line Rasterization and Grid Traversal
Click on grid to plot lines using one of the following algorithms:
- Bresenham's line algorithm - Suitable for displaying lines visually. Endpoints must be clamped to integral values.
- Exact - Captures all discrete grid points the line passes through. A naive implementation written by me.
- Amanatides-Woo voxel traversal algorithm in 2D - A fast voxel traversal algorithm implemented here in two dimensions.
Cursor coordinate:
Algorithm:
Source code: [ demo.js ] [ bresenham.js ] [ exact.js ] [ amanatides_woo.js ]