Intersection functions sometimes do not provide correct results with relative and absolute tolerance
romanarust opened this issue · 3 comments
Describe the bug
Tolerance comparison might not work anymore if coordinate values are high, but geometry is tiny.
To Reproduce
>>> from compas.geometry import Point, Line, intersection_segment_segment
>>> l1 = Line(Point(x=2687403.6546, y=1169130.8538, z=0.0), Point(x=2687403.6428, y=1169130.8540, z=0.0))
>>> l2 = Line(Point(x=2687403.6408, y=1169130.8538, z=0.0), Point(x=2687403.6509, y=1169130.8544, z=0.0))
>>> intersection_segment_segment(l1, l2, tol=1e-3)
(None, None)
Expected behavior
The intersection point should be [2687403.64386, 1169130.85398, 0.0]
Hi @romanarust is it possible that the diameter of the sphere representing the tolerance would be larger than the radii of the 2 lines?
@jf--- we discussed at length on slack yesterday. the result is because of the tol
value used, but that is because we use this value in the wrong way in one of the functions called by the intersection function.
intersection_segment_segment
calls intersection_line_line
, which in turn uses intersection_line_plane
. the problem is with intersection_line_plane
.
when users specify a tol
value to intersection_segment_segment
they would rightly assume it influences the precision of the intersection check. however, intersection_line_plane
uses the same value for a parallelity check where it has the opposite effect.
if we no longer pass on the tolerance value to intersection_line_plane
(which we actually shouldn't) everything works as expected...
exactly, thanks @tomvanmele