Boost logo

Geometry :

Subject: [geometry] segment_ratio<__int64> causes a real number value corruption in boost::geometry::difference()
From: sonic (mike.vasiljevs_at_[hidden])
Date: 2015-04-01 17:13:28

To make the story short double value


gets converted into


when calling /boost::geometry::difference()/ on two polygons. Polygons were
defined in a standard way, that is:


typedef boost::geometry::model::d2::point_xy<double> point_xy;
typedef boost::geometry::model::polygon<point_xy > polygon;/

I found (after 2.5 hours being lost in the haunted template forest :p) that
the culprit is the following code (or I am d hing terribly wrong):

/ set<0>(point, boost::numeric_cast<coordinate_type>(
                get<0, 0>(segment)
                    + ratio.numerator() * dx / ratio.denominator()));/

location: /boost\geometry\policies\relate\intersection_points.hpp/
Which curiously enough means that value was stored/manipulated NOT a
*double* but as a /*rational number*/!

Were there any gobrutaly to handle this problem without having to bluntly
round off the values?

Would be happy to post an example if there are any answers to follow...

boost version: 1.56.0

View this message in context:
Sent from the Boost Geometry mailing list archive at

Geometry list run by mateusz at