Boost C++ Libraries: Ticket #10868: Intersecting integer polygons produces incorrect or self-intersecting result https://svn.boost.org/trac10/ticket/10868 <p> I've noticed several instances of Boost.Geometry returning incorrect or self-intersecting polygons when working in integers (32 and 64 bit). </p> <p> EXAMPLE: Polygon A has vertices (42817136,-3774506), (43029074,-3929862), (31446819,18947953), (30772384,19615678), (30101303,19612322), (30114725,16928001), (33520458,6878575), (35332375,2413654), (35725796,2024148), (42817136,-3774506) </p> <p> Polygon B has vertices (-33386239,-33721784), (33721785,-33386239), (33386240,33721785), (-33721784,33386240) </p> <p> Intersecting Polygon A and Polygon B returns: </p> <p> A correct but self-intersecting polygon using Boost 1.55 </p> <p> An incorrect polygon using Boost 1.57 and int64_t coordinates </p> <p> An incorrect and self-intersecting polygon using Boost 1.57 and int32_t coordinates. </p> <p> For both Boost 1.57 tests, I enabled BOOST_GEOMETRY_NO_ROBUSTNESS to avoid floating point rescaling. </p> en-us Boost C++ Libraries /htdocs/site/boost.png https://svn.boost.org/trac10/ticket/10868 Trac 1.4.3 Barend Gehrels Fri, 02 Jan 2015 17:47:30 GMT component changed; cc, owner set https://svn.boost.org/trac10/ticket/10868#comment:1 https://svn.boost.org/trac10/ticket/10868#comment:1 <ul> <li><strong>cc</strong> <span class="trac-author">barend@…</span> added </li> <li><strong>owner</strong> set to <span class="trac-author">Barend Gehrels</span> </li> <li><strong>component</strong> <span class="trac-field-old">None</span> → <span class="trac-field-new">geometry</span> </li> </ul> Ticket mkaravel Thu, 26 Mar 2015 11:05:01 GMT <link>https://svn.boost.org/trac10/ticket/10868#comment:2 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/10868#comment:2</guid> <description> <p> Hi. </p> <p> AFAIC, the macro BOOST_GEOMETRY_NO_ROBUSTNESS has nothing to do with your findings, as rescaling is only activated for floating-point coordinates. </p> <p> I tried your example polygons, and I could reproduce the problem when the coordinate type is int32_t, but could not reproduce it for int64_t. Could you please check again against the latest Boost.Geometry version in the develop branch, and also report the output polygons you get? </p> <p> My understanding is that your polygons are CCW and open. Correct? </p> <p> Menelaos </p> </description> <category>Ticket</category> </item> <item> <author>starinshak1@…</author> <pubDate>Wed, 27 May 2015 21:27:18 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/10868#comment:3 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/10868#comment:3</guid> <description> <p> Replying to <a class="ticket" href="https://svn.boost.org/trac10/ticket/10868#comment:2" title="Comment 2">mkaravel</a>: </p> <p> Hi Menelaos, </p> <p> The polygons in my original example are CCW and closed. In testing, I initialize them with an open string of coordinates can call boost::geometry::correct to close them. </p> <p> Using the 1.58.0 release of Boost.Geometry, I now reproduce your findings for this problem: the polygon resulting from the intersection is self-intersecting for int32_t coordinates but non-self-intersecting for int64_t coordinates. However, when you plot the result, it is incorrect for both integer types (and incorrect in different ways). </p> <p> I have another example that further compounds this error: POLYGON((241774944 270613768, 249104265 268648604, 258263822 277993222, 262822082 304885727, 253206525 344982011, 240074874 272654983)) POLYGON((225182076 225182076, 292290940 225182076, 292290940 292290940, 225182076 292290940)) </p> <p> These are also CCW-oriented polygons. I now get the reverse behavior as the original example: </p> <p> If I intersect them using int32_t coordinates, the result POLYGON((252873436 292290940, 240074874 272654983, 241774944 270613768, 249104265 268648604, 258263822 277993222, 268109663 336081032, 252873436 292290940)) does NOT self-intersect. </p> <p> If I intersect them using int64_t coordinates, the result POLYGON((240075109 272653826, 240074874 272654983, 241774944 270613768, 249104265 268648604, 258263822 277993222, 262823538 304883653, 240075109 272653826)) does self-intersect. </p> <p> As before, the polygon resulting from the intersection is not correct. </p> <p> Dave </p> <blockquote class="citation"> <p> Hi. </p> <p> AFAIC, the macro BOOST_GEOMETRY_NO_ROBUSTNESS has nothing to do with your findings, as rescaling is only activated for floating-point coordinates. </p> <p> I tried your example polygons, and I could reproduce the problem when the coordinate type is int32_t, but could not reproduce it for int64_t. Could you please check again against the latest Boost.Geometry version in the develop branch, and also report the output polygons you get? </p> <p> My understanding is that your polygons are CCW and open. Correct? </p> <p> Menelaos </p> </blockquote> </description> <category>Ticket</category> </item> </channel> </rss>