boostorg / boostorg/geometry

boost::geometry::intersection produces wrong result

Open
#510 2 comments 0 reactions 0 assignees View on GitHub
Dominant language
C++
Stars
517
Forks
232
PR merge metrics
No merged PRs in 30d

Description

Hi everyone. I've just noticed unit test which produced correct result on boost 1.55, but it fails on 1.67
Is that known? No matter if clippingRegion is defined in CW or CCW direction, it always gives me 2 lines as a result of intersection. But with the same input old boost gave me 1 (but very small) correct subsegment as a result.

Could you please help with that?
```
#include
#include
#include
#include
using namespace boost::geometry::model;
using namespace boost::geometry;

typedef d2::point_xy BoostPoint;
typedef polygon BoostPolygon;
typedef linestring BoostPolyline;

int main(void)
{
BoostPolyline polyToClip;
std::vector clippingResult;

polyToClip.push_back(BoostPoint(-7.7866132709658586e-005, 6.0810736257569502));
polyToClip.push_back(BoostPoint(-7.7866132709658586e-005, -6.0811651098339610));

multi_polygon clippingRegion;
BoostPolygon curPolygon;
append(curPolygon, BoostPoint(0.084821928797522289, 1.9999244955432876));
append(curPolygon, BoostPoint(1.8813618198054716e-016, 2.0001895226089994));
append(curPolygon, BoostPoint(-7.7866133709978802e-005, 1.9997988605928652));
append(curPolygon, BoostPoint(0.00000000000000000, 1.9994081985767305));
append(curPolygon, BoostPoint(0.00000000000000000, -2.0001895226089998));
append(curPolygon, BoostPoint(0.084821928797522289, 1.9999244955432876));
clippingRegion.push_back(curPolygon);
reverse(clippingRegion);

intersection(clippingRegion, polyToClip, clippingResult);
return 0;
}
```

Here you can see how polyToClip (red and pink) gets separated by point 2 of clippingRegion (green). But even If I change direction of clippingRegion - it still produces the same result.

![image](https://user-images.githubusercontent.com/4762581/45877743-8d24fe00-bda7-11e8-9428-d40bb9e2d640.png)

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.