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

Intersection gives incorrect result for polygon and line #1253

Open
jdmarsh opened this issue Feb 29, 2024 · 1 comment
Open

Intersection gives incorrect result for polygon and line #1253

jdmarsh opened this issue Feb 29, 2024 · 1 comment
Labels

Comments

@jdmarsh
Copy link

jdmarsh commented Feb 29, 2024

I have a polygon and line which intersects at the very corner, the intersection result is much larger than it should be. The godbolt repro is here: https://godbolt.org/z/TEEaqvcT1

Polygon(red) and line(green)
image

Intersection result(blue) goes way outside of the red triangle, down to the bottom left
image

I don't really care whether the actual result is super accurate or not, I don't need a high level of precision, I just need the result to be somewhat sensible and not creating huge lines outside the boundaries of the polygons I'm using to intersect.

@vissarion
Copy link
Member

I can reproduce the issue. Thanks.

The algorithm incorrectly generates the intersection segments using the computed intersection points and the original endpoints of the input segment. Note that if you compute the intersection points (instead of intersection segments) you will get a good approximation. i.e. std::vector<Point2D> intersections

@vissarion vissarion added the bug label Mar 26, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants