Opened 4 years ago

Last modified 4 years ago

#13636 new Bugs

distance calculation can be wrong for rings with collinear segments

Reported by: stfn <p1433025@…> Owned by: Barend Gehrels
Milestone: To Be Determined Component: geometry
Version: Boost 1.67.0 Severity: Problem
Keywords: distance ring collinear pythagoras segment Cc:

Description

While unit-testing our code using boost::geometry, I stumbled upon a weird distance calculation: For two rings that are perfect 2d boxes and share the orientation and one segment length, their distance is calculated as zero although they are clearly not intersecting:

https://wandbox.org/permlink/Z9DMLo52IdhZRCFb

I made a rough sketch of the situation: https://www.desmos.com/calculator/7jbmeu9jqq.


Note the line

// slightly change the values
vehicleRing[2] = Point2D(vehicleRing[2].x() + 1e-10, vehicleRing[2].y() + 1e-10);

.. changing vehicleRing[0] or vehicleRing[1] also results in zero distance, whereas slightly moving vehicleRing[2] results in the expected distance.


Sorry for being lazy and not finding a simpler test-case (resp. simpler numbers), I just copied the values I generated in my own testing pipeline.

Change History (2)

comment:1 by stfn <p1433025@…>, 4 years ago

Note: See TracTickets for help on using tickets.