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 point in nonconvex Polygon check #3126

Closed
mforets opened this issue Oct 12, 2022 · 3 comments · Fixed by #3628
Closed

Add point in nonconvex Polygon check #3126

mforets opened this issue Oct 12, 2022 · 3 comments · Fixed by #3628

Comments

@mforets
Copy link
Member

mforets commented Oct 12, 2022

cc @mvanzulli

@schillic schillic changed the title Add point in VPolygonNC check Add point in nonconvex Polygon check May 17, 2023
@David-davidlxl
Copy link

David-davidlxl commented Jul 28, 2024

I wanted to see if there's any progress on this. I'm working with a nonconvex polygon and I'd really like to have the membership-check functionality.
For example, I'd like the following code to run without error:

using LazySets
polygon = Polygon([[0, 0],
    [2.1314, 0.9141],
    [1.8282, 1.2219],
    [0.9141, 0.9141],
    [0.6063, 1.5251],
    [-0.6063, 2.1360],
    ])
println([1, 1] ∈ polygon)

Update:
The code

using LazySets
polygon = VPolygon([[0, 0],
    [2.1314, 0.9141],
    [1.8282, 1.2219],
    [0.9141, 0.9141],
    [0.6063, 1.5251],
    [-0.6063, 2.1360],
    ], apply_convex_hull=false)
println([1, 1] ∈ polygon)

does appear to produce the correct result, even though it's inconsistent with plot(polygon) (#3127 (comment))

@schillic
Copy link
Member

@David-davidlxl: I added an implementation in #3628. It will likely take some time until this gets reviewed and merged, so I suggest you check out the branch or copy the code.
Also, I tried to cover every edge case, but there might be one missing. So feel free to beta-test it :)

@David-davidlxl
Copy link

@schillic Thank you so much!
I copied your ∈(x::AbstractVector, P::Polygon) function and tested it with my polygon, and it seems to work perfectly! #3628
image

schillic added a commit that referenced this issue Nov 19, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants