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

bg::intersection result is the second input polygon instead of empty polygon #1201

Open
snowman791 opened this issue Sep 14, 2023 · 1 comment
Assignees

Comments

@snowman791
Copy link

on version 1.83 the bg::Intersection generates wrong result for this specific case. The result polygon is same as the second input polygon Q.
When the first polygon P has instead of the value 1e-14 eg. 1e-13 or 1e-15, the result is empty, which is correct.

using boost_point_2d = boost::geometry::model::d2::point_xy;
using boost_polygon_2d = boost::geometry::model::polygon<boost_point_2d, false>;
using boost_multipolygon_2d = boost::geometry::model::multi_polygon<boost_polygon_2d>;

boost_polygon_2d P = {{{1e-14, 0}, {-10, 50}, {-20, 50}, {1e-14, 0}}};
boost_polygon_2d Q = {{{0, 1000}, {0, 0}, {1000, 0}, {1000, 1000}, {0, 1000}}};
boost_multipolygon_2d R;

bg::intersection(P, Q, R);
image

@vissarion
Copy link
Member

A side note: the correct result is not empty, it is a triangle

MULTIPOLYGON(((0 p1,1e-14 0,0 p2,0 p1)))

where p1, p2 are intersection points of the segments (-10 50, 1e-14 0) and (-20 50, 1e-14 0) with segment (0 0, 0 1000).

So, I think both results you get are wrong.

@barendgehrels barendgehrels self-assigned this Nov 24, 2024
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

No branches or pull requests

3 participants