Skip to content

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

Open

Description

@romanarust

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]

Activity

  1. jf--- commented on Apr 11, 2024

    @jf---
    Contributor

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

  2. tomvanmele commented on Apr 11, 2024

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

  3. romanarust commented on Apr 11, 2024

    @romanarust
    MemberAuthor

    exactly, thanks @tomvanmele

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions