Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Intersection functions sometimes do not provide correct results with relative and absolute tolerance #1320

Open
romanarust opened this issue Apr 10, 2024 · 3 comments

Comments

@romanarust
Copy link
Member

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]

@jf---
Copy link
Contributor

jf--- commented Apr 11, 2024

Hi @romanarust is it possible that the diameter of the sphere representing the tolerance would be larger than the radii of the 2 lines?

@tomvanmele
Copy link
Member

@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...

@romanarust
Copy link
Member Author

exactly, thanks @tomvanmele

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants