compas-dev / compas-dev/compas

Results of intersection_line_line_xy and intersection_line_line are different

Open
#1,398 0 comments 0 reactions 1 assignee Claimed by @tomvanmele View on GitHub
bug
Dominant language
Python
Stars
386
Forks
122
Avg merge
11d 46m
Merged PRs (30d)
1

Description

I'm not sure if this is related to [issue #1320](https://github.com/compas-dev/compas/issues/1320), but it also involves high coordinate values.

`intersection_line_line_xy` and `intersection_line_line` are producing different intersection points. The result from `intersection_line_line` is correct, while the one from `intersection_line_line_xy` is not. This discrepancy is clearly related to the high coordinate values, as both functions return identical results when the lines are transformed closer to the origin.

**To Reproduce**
```
>>> from compas.geometry import Line
>>> from compas.geometry import Point
>>> from compas.geometry import Translation
>>> from compas.geometry import Vector
>>> from compas.geometry import distance_point_point
>>> from compas.geometry import intersection_line_line
>>> from compas.geometry import intersection_line_line_xy
>>> line_a = Line(Point(x=2687071.524742563, y=1221749.0753872169, z=0.0), Point(x=2687069.1419153824, y=1221750.3200979184, z=0.0))
>>> line_b = Line(Point(x=2687069.1328718644, y=1221750.3261498366, z=0.0), Point(x=2687069.006655604, y=1221750.4317925072, z=0.0))
>>> tol = 1e-7
>>> i2d = intersection_line_line_xy(line_a, line_b, tol=tol)
>>> i3d = intersection_line_line(line_a, line_b, tol=tol)[0]
>>> distance_point_point(i2d, i3d)
0.005755306379571995
>>> T = Translation.from_vector(Vector.from_start_end(line_a[0], (0, 0, 0)))
>>> line_a.transform(T)
>>> line_b.transform(T)
>>> i2d = intersection_line_line_xy(line_a, line_b, tol=tol)
>>> i3d = intersection_line_line(line_a, line_b, tol=tol)[0]
>>> distance_point_point(i2d, i3d)
4.965068306494546e-16
```

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.