-
Notifications
You must be signed in to change notification settings - Fork 32
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
Add Sutherland–Hodgman VPolygon intersection algorithm #2345
Conversation
if the intersection is empty the new function should rather return |
Co-authored-by: Christian Schilling <[email protected]>
if isempty(v12) | ||
return EmptySet{N}(2) | ||
else | ||
return VPolygon(v12, apply_convex_hull=apply_convex_hull) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
IMO VPolygon
s should always be created using a convex hull unless the algorithm guarantees that result anyway.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes , i agree. i left the option as true
by default.
Co-authored-by: Christian Schilling <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I still think the option apply_convex_hull
is misleading because you may want to set it to false
to save time, but that will violate our type assumption of VPolygon
.
yes, but if an application just requires the vertices of the intersection (without any particular sorting assumption) it's reasonable to pass |
This is a standard algorithm, see https://en.wikipedia.org/wiki/Sutherland%E2%80%93Hodgman_algorithm. The code follows that of http://www.rosettacode.org/wiki/Sutherland-Hodgman_polygon_clipping#Julia.
Related to #698.