jscad / OpenJSCAD.org

JSCAD is an open source set of modular, browser and command line tools for creating parametric 2D and 3D designs with JavaScript code. It provides a quick, precise and reproducible method for generating 3D models, and is especially useful for 3D printing applications.
https://openjscad.xyz/
MIT License
2.63k stars 512 forks source link

checkIfConvex for transformed polygon is failing #41

Closed ZhekaS closed 7 years ago

ZhekaS commented 10 years ago

The next piece of code will fail with "Not convex" exception:

function main() {
   var points = [ 
            [ 1,  1, 0],
            [-1,  1, 0],
            [-1, -1, 0],
            [ 1, -1, 0]
    ]
   var p = CSG.Polygon.createFromPoints(points);
   var m = CSG.Matrix4x4.rotation([0,0,0], [-0.56, 0.83, 0.00], 110);

   p.transform(m).checkIfConvex();

   return cube([0,0,0], 2)
}

It looks that it is failing whenever the polygon's normal vector is changing it's sign relatively to the original plane. But I am not sure.

z3dev commented 7 years ago

This issue was moved to jscad/csg.js#18