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

extrude twist can cause invalid geometry #563

Closed
pca006132 opened this issue Sep 27, 2023 · 5 comments · Fixed by #589
Closed

extrude twist can cause invalid geometry #563

pca006132 opened this issue Sep 27, 2023 · 5 comments · Fixed by #589

Comments

@pca006132
Copy link
Collaborator

I was thinking about the twist parameter when I was looking at offset extrude. It seems that the twist parameter can cause invalid geometry when the nDivisions is small. This problem also exists in OpenSCAD (which does not use our extrude algorithm) so this is pretty general.

Extruding a square with twist=180 and nDivisions=0 (not necessarily invalid, I am just showing here because it is a simpler case):
image

Extruding a concave polygon (square(glm::vec2(2), false) - square(glm::vec2(1), false) with twist=180 and nDivisions=0:
image

@hrgdavor
Copy link

I would call this user issue, not library issue. :)

@pca006132
Copy link
Collaborator Author

I would call this user issue, not library issue. :)

I think it depends on how you view the APIs. For example, the documentation of the warp function explicitly says that it is very easy to create self-intersections and we do not check them now.

The way I see this is that, except certain APIs that we have warned the users, geometrically valid inputs should result in geometrically valid output. Anything violating this is a bug. (which we can also 'fix' by saying that the user should pay attention to blablabla...)
For this case, it is not easy to see what is the minimal number of segments to create a valid result.

@elalish
Copy link
Owner

elalish commented Sep 28, 2023

I look at this exactly like the Warp function, and you're right that it should probably have a similar warning. I am planning to try and implement an overlap removal algorithm, in which case that can be run automatically after operations like these.

@pca006132
Copy link
Collaborator Author

@platypii suggested we can rotate the points to avoid getting self-intersections, though it will only work if the points are evenly spaced.

Wonder if this can work in general if we interpolate the points into segments with roughly the same lengths? One problem is that the geometry will be different even for cases that there are no self-intersections.

@elalish
Copy link
Owner

elalish commented Sep 28, 2023

I think that's a little too clever - could easily surprise users. Let's wait for a proper solution that will handle Warp as well.

@pca006132 pca006132 mentioned this issue Nov 2, 2023
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

Successfully merging a pull request may close this issue.

3 participants