jscad / csg.js

DEPRECATED: CSG Library for JSCAD (See the link below)
https://github.com/jscad/OpenJSCAD.org/tree/master/packages/modeling
MIT License
218 stars 56 forks source link

tolerence for comparing unit normals #142

Closed z3dev closed 5 years ago

z3dev commented 5 years ago

There are several places in the code where the distances between the unit normals are being compared. Unit normals have a different maginitude of precision than points in 3D space, and therefore the library should have a different a epsilon when comparing unit normals.

http://jcgt.org/published/0003/02/01/paper.pdf

This is even more important if someone 'adjusts' the epsilon for designs.

z3dev commented 5 years ago

See fuzzyfactory/FuzzyFactory3, geom3/project, etc.

pentacular commented 5 years ago

I suggest that instead of comparing distances, we simply quantize space to some resolution.

Only vectors that represent points in geometric space need be quantized, providing that incremental error is avoided.

(This means that unit vectors can be left at full precision)

One approach is to have geometries hold a base, untransformed structure, and to generate a transformed quantized structure from the base structure when expressing the geometry in a particular spatial arrangement.

When merging geometries via union, etc, they would need to be expressed in the same quantized space so that they could agree on precise face, etc, arrangement.

To recap -- how about we consider quantized points in space, and unquantized abstract geometries, and avoid incremental operations upon the abstract geometry?

z3dev commented 5 years ago

Great. Let’s go with this approach. Can you add this to the documentation that you have?

z3dev commented 5 years ago

Bascially, normals should be compare for equality, period. Closing this issue.