block by bmershon 4d728745019412527bf733f0bd098a0a

Polygon Clipping Degeneracies

Full Screen

Testing Mike Bostock’s Sutherland-Hodgman clipping implementation.

The scissors implementation of a scissors-congruence between two polygons of equal area suffers from numerical instability in the clipping stage of the pipeline. The current implementation of clipping simply clips two collections of polygons against one another.

This example demonstrates areas where new vertices are created while highlighting areas where floating-point precision issues may arise.

Note that the clipping polygon must be convex for Sutherland-Hodgman to work correctly. Move the control points by dragging them.

index.html

d3-polygon-clip.js