Source code: http://github.com/evanw/csg.js/
Documentation: http://evanw.github.com/csg.js/docs/
These tests cover all the cases of a pair of overlapping coplanar polygons in both solids. To avoid duplicate polygons, the overlapping polygons are kept in the first solid and removed from the second solid.
a |
b |
a.inverse() |
b.inverse() |
a.union(b) |
b.union(a) |
a.subtract(b) |
b.subtract(a) |
a.intersect(b) |
b.intersect(a) |
c |
d |
c.inverse() |
d.inverse() |
c.union(d) |
d.union(c) |
c.subtract(d) |
d.subtract(c) |
c.intersect(d) |
d.intersect(c) |