csg.js icon indicating copy to clipboard operation
csg.js copied to clipboard

CSG.Polygon assumes no collinear edges

Open ericu opened this issue 12 years ago • 4 comments

If you try to create a CSG.Polygon, passing in a series of vertices where the first 3 are collinear, the calculation of the plane normal will be wrong. The documentation for the function only requires that the polygon be planar and convex, not that it contain no degeneracies; either the code or the docs should change.

ericu avatar Sep 29 '12 03:09 ericu

The problem is at the polygon constructor. There it constructs a plane from the first three points. If these are colinear they should not be used untill none colinear are found.

janhelleman avatar Jan 08 '15 12:01 janhelleman

That looks like a relatively easy fix, but I'm not sure that this repository is still being maintained.

NateTG avatar Feb 21 '15 02:02 NateTG

@NateTG I think I've seen issues in my app related to this. Would really appreciate a fix if you have the time and energy.

razola avatar Feb 23 '15 13:02 razola

I'm still a js neophyte, but the changes at:

https://github.com/NateTG/csg.js

Should support polygons with some non-colinear edges.

NateTG avatar Feb 23 '15 17:02 NateTG