Skip to content

fix(geom3d): return the intersection point of two lines - #273

Open
Doribelove wants to merge 1 commit into
rai-opensource:masterfrom
Doribelove:fix/line-intersection-point
Open

Doribelove wants to merge 1 commit into
rai-opensource:masterfrom
Doribelove:fix/line-intersection-point

Conversation

@Doribelove

Copy link
Copy Markdown
Contributor

Line3.intersects() returns a (3, 3) array for intersecting lines instead of the documented (3,) intersection point:

from spatialmath import Line3

a = Line3.PointDir([1, 2, 3], [1, 0, 0])
b = Line3.PointDir([1, 2, 3], [0, 1, 0])
a.intersects(b)  # expected array([1., 2., 3.])

The final multiplication in the old expression broadcasts a matrix. Normalizing the cross product also rejects some valid lines represented with small Plücker coordinates.

After the existing intersection predicate succeeds, reuse closest_to_line() to obtain the intersection point. Keep the predicate, tolerance and None result for parallel, coincident and skew lines unchanged. Correct the method's malformed related-method links.

Add 18 regression cases covering the origin and translated intersections, nonorthogonal and spatial directions, either operand order, positive/negative and unequal Plücker scales, and nonintersecting controls.

Validation with current upstream 41e0a4d:

  • New regressions before the fix: 15 failed, 3 passed; geometry tests after the fix: 60 passed.
  • Full suite on Python 3.12.14: 428 passed, 3 skipped, with 55 subtests passed and 22 warnings.
  • Geometry tests on Python 3.10.12: 60 passed, with 2 warnings.
  • Repository pre-commit hooks (including Black 23.10.0) and git diff --check pass.

Signed-off-by: 李永祺 <doribelove@gmail.com>

This branch has not been deployed

No deployments
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

Successfully merging this pull request may close these issues.

1 participant