#7462 closed Bugs (fixed)
geometry::union_ yields degenerated results
Reported by: | Owned by: | Barend Gehrels | |
---|---|---|---|
Milestone: | To Be Determined | Component: | geometry |
Version: | Boost 1.48.0 | Severity: | Problem |
Keywords: | Cc: |
Description
The following data gives wrong results with geometry::union.
float data1[][2] = {{0,0}, {-0.3681253195,0.9297761917}, {2.421203136,2.034152031}, {2.789328575,1.104375958}, {0,0}}; float data2[][2] = {{2.76143527,1.093332171}, {2.076887131,1.822299719}, {4.263789177,3.875944376}, {4.948337555,3.146976948}, {2.76143527,1.093332171}}; polygon_t p1, p2; boost::geometry::append(p1, data1); boost::geometry::append(p2, data2); std::vector<polygon_t> output; boost::geometry::union_(p1, p2, output);
Please find attached the whole main file and program output.
Attachments (2)
Change History (6)
Changed 6 years ago by
Attachment: | boost_geometry_union_bug.cpp added |
---|
Changed 6 years ago by
Attachment: | boost_geometry_union_bug_output.txt added |
---|
comment:1 Changed 6 years ago by
comment:2 Changed 5 years ago by
Resolution: | → fixed |
---|---|
Status: | new → closed |
(In [83481]) [geometry] Fix ticket 7462, degenerate union for float. This was caused by two distances being wrong (by floating point precision). We now use earlier the alternative sort method (sorting on left/right), using relaxed_epsilon. This fixes the cause.
comment:4 Changed 5 years ago by
Replying to barendgehrels:
(In [83482]) [geometry] Fix ticket 7462, (unit tests)
Thanks for fixing this!
Note: See
TracTickets for help on using
tickets.
Actually union(p1,p2) yields a degenerated polygon while union(p2,p1) gives the correct result. In my use case, wrong results occur in ~0.5% of the cases.