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

Add edge intersection test to Contains3D #767

Open
ikeough opened this issue Feb 3, 2022 · 3 comments
Open

Add edge intersection test to Contains3D #767

ikeough opened this issue Feb 3, 2022 · 3 comments
Assignees
Labels
Enhancement New feature or request Geometry
Milestone

Comments

@ikeough
Copy link
Contributor

ikeough commented Feb 3, 2022

It might not be enough to only check vertices in non-convex cases. Consider to check edge intersections, see image.

afbeelding

Originally posted by @aothms in #638 (comment)

@ikeough ikeough added Enhancement New feature or request Geometry labels Feb 3, 2022
@ikeough ikeough added this to the 2.0 milestone Apr 17, 2023
@ikeough ikeough self-assigned this Apr 17, 2023
@ikeough ikeough modified the milestones: 2.0, 0.2.1, 2.1 Apr 17, 2023
@DmytroMuravskyi
Copy link
Contributor

There is Cover function that also checks Polygon and it checks for edge intersections but it's 2d oriented (uses Intersects2d). Its logic can be reused in Contains with adjustment that Contains only wants Inside result and not CoincidesAtEdge/Vertex.

It will fix this problem, but, in my opinion, there is some confusion between Cover/Contains/Contains3d functions.

  • Some functions use Clipper lib: bool Contains(Polygon polygon) and bool Covers(Vector3 vector) while other have custom implementation.
  • All Covers function state that they return true when "is within this Polygon or coincident with an edge" while Contains - "without coincidence with an edge or vertex". But Contains3D (and a function calling it) says "is within this Polygon or coincident with an edge." and returns accordingly breaking understanding of difference between the two.
  • Some functions say "when compared on a shared plane." but they work only on XY plane, like bool Contains(Polygon polygon) where Clipper with 2d IntPoint is used or bool Covers(Polygon polygon) where Intersects2d is called.

In my opinion, ideally, there should be one private implementation (based on Clipper or custom implementation) for Point-Polygon containment and one for Polygon-Polygon containment that works efficiently on XY plane and different public function can be built on top of it depending on how they treat CoincidesAtEdge/Vertex case, do they expect 2d or 3d input. And if 3d input is expected then shared plane is first converted to XY plane.

@wynged
Copy link
Member

wynged commented Oct 27, 2023

how long do you think the larger effort would take? I think if we can time box it to 1/2 days, fix this bug, and preserve existing tests then it sounds like a good idea. If it's a longer effort let's do the quick fix for now and maybe make another issue to track these findings, but it doesn't have to be part of 2.1 milestone.

@DmytroMuravskyi
Copy link
Contributor

DmytroMuravskyi commented Oct 27, 2023

The changes will fit in two days as all code is there it's just about interface being clear and code is reused. It's good idea to create another issue for this as it would require same amount of discussion. I'll focus on adding edge intersection test to Contains3D as well as make sure that all functions reusing the same internal algorithms.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Enhancement New feature or request Geometry
Projects
None yet
Development

No branches or pull requests

3 participants