Modify ↓
Opened 2 years ago
Last modified 2 years ago
#11470 new Bugs
Invalid results using convex_hull with unsigned integer points coordinates
Reported by: | Owned by: | Barend Gehrels | |
---|---|---|---|
Milestone: | To Be Determined | Component: | geometry |
Version: | Boost 1.58.0 | Severity: | Problem |
Keywords: | Cc: |
Description
Hi, I think convex_hull algorithm does not support unsigned integer points coordinates.
The following code works well with signed integer but return a wrong result for unsigned version :
#include <boost/geometry.hpp> #include <boost/geometry/geometries/point_xy.hpp> #include <boost/geometry/geometries/polygon.hpp> #include <deque> int main() { typedef boost::geometry::model::d2::point_xy<unsigned int> PointInt; typedef boost::geometry::model::polygon<PointInt> polygon_type; polygon_type poly1, convPoly1; polygon_type poly2, convPoly2; boost::geometry::read_wkt("POLYGON((245 143, 243 113, 236 101, 228 100, 222 106, 217 121, 217 144, 220 155, 227 165, 233 166, 237 163, 245 143))", poly1); boost::geometry::convex_hull(poly1, convPoly1); return 0; }
Attached file is a representation of input polygon (orange) and output result (blue) curve.
Attachments (1)
Change History (3)
Changed 2 years ago by
Attachment: | Clipboard02.tif added |
---|
comment:1 Changed 2 years ago by
comment:2 Changed 2 years ago by
Hi,
I just come to the news, will that bug be planned for correction ?
Regards, Eric Noirfalise
Note: See
TracTickets for help on using
tickets.
Ok after some code exploration I think that problem comes from :
in file boost/geometry/trategies/cartesian/side_by_triangle.hpp
In my case :
So, for example, on line
a case where y < sy1 will lead to wrong result. A simple cast of y to PromotedType? like
should in my case solve the problem.
If my understanding is good, PromotedType? will be the most precise type between double and CoordinateType?. So if I use input unsigned int 64, a similar error can happen and my correction will fail...