Graphics / Reference / Edge intercepts via DDA

Edge intercepts via DDA

Triangle scanline boundaries can be generated by DDA-style edge walkers. Each active edge stores its current x intersection and advances that value by a constant change in x for every one-row change in y.

Polygon filling can reuse an incremental line method to advance along each active polygon edge and obtain the x positions where the current scanline crosses that edge.

For triangle edges AB and AC, define their change in x per one-unit change in y as:

m_AB = (xB - xA)/(yB - yA)

m_AC = (xC - xA)/(yC - yA)

If the current scanline intersects the edges at x_AB and x_AC, then moving from row y to y' = y + 1 updates the intersections incrementally:

x'_AB = x_AB + m_AB

x'_AC = x_AC + m_AC

The same DDA principle applies to any active edge: keep its current real-valued intersection and add a fixed per-row increment instead of solving the edge equation again from scratch.

On each scanline, the current edge intersections determine the horizontal fill span. When an active edge ends at a polygon vertex, the walker for that edge is replaced by the next boundary edge.

The standard diagram labels current and next-row intersections on triangle edges across adjacent scanlines.

Two adjacent scanlines cross triangle edges AB and AC; labelled intersection positions move by fixed increments of one and one third on the next row.
Advancing one scanline adds each edge's fixed x-per-row increment to its current intersection.

Builds on

Read

Playgrounds