OpenJSCAD.org icon indicating copy to clipboard operation
OpenJSCAD.org copied to clipboard

Is poly2 always convex?

Open jue89 opened this issue 2 years ago • 4 comments

The API description states that poly2 is always convex: https://github.com/jscad/OpenJSCAD.org/blob/f5f31084843adebaeb481c064eb09634fb7490a0/packages/modeling/src/geometries/poly2/create.js#L2

But looking in the code, poly2 is created from geom2 outlines, which may not be convex: https://github.com/jscad/OpenJSCAD.org/blob/f5f31084843adebaeb481c064eb09634fb7490a0/packages/modeling/src/operations/expansions/offsetGeom2.js#L28-L30

Is this a possible bug? Or is the documentation outdated?

jue89 avatar Dec 21 '21 13:12 jue89

Ah… poly2… it was added as part of V2 but is not really 100%. So, I’m not sure where this geometry will be useful. I believe it was added to scope those special functions.

Do you have some use cases?

z3dev avatar Dec 21 '21 21:12 z3dev

I was just wondering. I looked into the code for existing parts useful for the implementation of the Minkowski sum. If poly2 isn't guaranteed to be convex, a poly2.isConvex() function would make sense. Some goes for a decompose function to split a non-convex polygon into convex polygons.

jue89 avatar Dec 24 '21 14:12 jue89

Ah. Now, I understand where this is going. Feel free to contribute functionality to poly2. Please follow name and style similar to poly3, if possible. And of course, some rudimentary tests.

z3dev avatar Dec 24 '21 22:12 z3dev

@jue89 theres a set of changes coming for poly2. Can you follow and add comments? Or even better... enhancements.

z3dev avatar Aug 13 '22 09:08 z3dev