Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Booleans are precision sensitive #676

Closed
zalo opened this issue Dec 27, 2023 · 3 comments
Closed

Booleans are precision sensitive #676

zalo opened this issue Dec 27, 2023 · 3 comments

Comments

@zalo
Copy link
Contributor

zalo commented Dec 27, 2023

@elalish 's request here: #669 (comment)

The results of Boolean Ops can differ depending on small differences in precision.

Here's a simple test with two cube manifolds unioned together by "exactly" touching faces:

cube      = Manifold.cube ([0.0999, 0.0999, 0.0999])
near_cube = cube.translate([0.0999 *  1, 0.0, 0.0]) + cube.translate([0.0999 *  2, 0.0, 0.0])
far_cube  = cube.translate([0.0999 * 50, 0.0, 0.0]) + cube.translate([0.0999 * 51, 0.0, 0.0]) # Should be the same, but further away
print("Near Cube Genus:", near_cube.genus(), ", Far Cube Genus:", far_cube.genus())

Near Cube Genus: 0, Far Cube Genus: -1

These problems exacerbate as faces rotate, extrude, dilate, etc. as seen in the Offset PRs and related BatchBoolean-based modelling.

I believe this is separate from the order-dependency/non-determinism bug...

@elalish
Copy link
Owner

elalish commented Dec 27, 2023

This is working as intended - I don't think 0.0999 * 51 is exactly representable in binary floating point, so you are creating rounding errors that cause the first to have identical verts and the second to not quite, so there's nothing our symbolic perturbation can do. We can only fix these marginal cases when the input verts are actually identical.

What I was asking for is simplified cases that return shard manifolds when the verts are identical (hence my use of Warp), and especially cases that generate overlapping polygons, which the triangulator then chokes on.

@elalish elalish closed this as completed Dec 27, 2023
@zalo
Copy link
Contributor Author

zalo commented Dec 28, 2023

Given that the Minkowski Sums are formed from Hulls (which lose all the symbolic perturbation information?), is there some way to synthetically reintroduce that back into the system?

Hrm, I suppose there shouldn’t be non-identical verts with that, but I have a suspicion that Hull moves the points around a bit… I’ll investigate that a bit later…

@elalish
Copy link
Owner

elalish commented Dec 28, 2023

It would be interesting if Hull moves the verts at all. Symbolic perturbation isn't really information to be lost - it just means that when verts have floating-point equal X, Y, or Z values, we break the tie by looking at the direction of the normals of one of the two input objects to decide which one is one which side of the other. The Boolean op itself uses the input float coordinates as though they are exact and doesn't use our precision at all, hence its robustness.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants