Skip to content

fix(geom3d): accept array-like volume bounds - #274

Open
Doribelove wants to merge 1 commit into
rai-opensource:masterfrom
Doribelove:fix/line-volume-arraylike-bounds
Open

Doribelove wants to merge 1 commit into
rai-opensource:masterfrom
Doribelove:fix/line-volume-arraylike-bounds

Conversation

@Doribelove

Copy link
Copy Markdown
Contributor

Line3.intersect_volume() documents six array-like bounds, but passing a Python list or tuple raises AttributeError at bounds.reshape(...). Row and column NumPy vectors also fail later because the face loop indexes the unflattened bounds.

from spatialmath import Line3

line = Line3.PointDir([0, 1, 2], [1, 0, 0])
line.intersect_volume([-2, 3, -1, 4, 0, 5]).p
# expected columns: [-2, 1, 2] and [3, 1, 2]
# before: AttributeError: 'list' object has no attribute 'reshape'

Normalize the bounds once with base.getvector(bounds, 6), as Line3.plot() already does. This accepts lists, tuples, flat arrays, and row/column vectors, and validates their length before the face loop. Correct the bounds type field and the reshape comment. The intersection algorithm and return structure are unchanged.

Add 21 regression cases for axis-aligned and oblique intersections, a line outside the volume, all five input formats, and invalid lengths. Check intersection coordinates, point-array shape and line parameters.

Validation against upstream 41e0a4d:

  • New regressions on the original runtime: 16 failed, 5 passed. All 21 pass with the fix.
  • Geometry tests on Python 3.12.14 and 3.10.12: 63 passed on each.
  • Full suite on Python 3.12.14: 431 passed, 3 skipped, with 55 subtests passed and 23 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