
Geometry : 
Subject: [geometry] segment_ratio<__int64> causes a real number value corruption in boost::geometry::difference()
From: sonic (mike.vasiljevs_at_[hidden])
Date: 20150401 17:13:28
To make the story short double value
"*1.3999999999999999*"
gets converted into
"*1.4000000000000057*"
when calling /boost::geometry::difference()/ on two polygons. Polygons were
defined in a standard way, that is:
/BOOST_GEOMETRY_REGISTER_C_ARRAY_CS(cs::cartesian)
BOOST_GEOMETRY_REGISTER_BOOST_ARRAY_CS(cs::cartesian)
BOOST_GEOMETRY_REGISTER_BOOST_TUPLE_CS(cs::cartesian)
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()));/
in:
function:
/boost::geometry::policies::relate::segments_intersection_points::assign(..)/
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: http://boostgeometry.203548.n3.nabble.com/segmentratioint64causesarealnumbervaluecorruptioninboostgeometrydifferencetp4026514.html Sent from the Boost Geometry mailing list archive at Nabble.com.
Geometry list run by mateusz at loskot.net