feat: add Arrow.FromTo(start, end) classmethod - #41
Merged
Conversation
Construct an Arrow spanning two points directly, without the caller having to compute length and pose by hand. Uses SE3.OA(reference, direction) to build the pose, not a delta rotation from a fixed reference (e.g. spatialmath's own SE3.RotatedVector) -- that approach has an antipodal singularity (direction exactly opposite the reference axis gives a zero-length cross product), confirmed live it currently returns identity instead of the correct 180 degree flip. OA sidesteps this entirely by directly specifying the target frame's axes. Companion fix proposed upstream: bdaiinstitute/spatialmath-python, branch fix/rotatedvector-antipodal. reference (the OA "orientation" vector) only needs to be non-parallel to direction -- irrelevant which valid one we pick, the arrow shaft is rotationally symmetric.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Arrow.FromTo(start, end, **kwargs)classmethod -- constructs anArrowspanning two 3-vectors, computinglengthandposeautomatically instead of requiring the caller to do it by hand.
**kwargspass straight through to the constructor (color,radius,linewidth,head_length,head_radius, ...).SE3.OA(reference, direction)to build the pose, not a deltarotation from a fixed reference -- that class of approach (e.g.
spatialmath's own
SE3.RotatedVector) has an antipodal singularity:confirmed live that
SE3.RotatedVector([0,0,1], [0,0,-1])currentlyreturns identity instead of the correct 180° flip, since the cross
product used to find the rotation axis is zero right at that point.
SE3.OAsidesteps this entirely by directly specifying the targetframe's axes rather than computing a delta from Z. Companion fix
proposed upstream for the underlying bug:
bdaiinstitute/spatialmath-python, branch
fix/rotatedvector-antipodal(PR to follow).
reference(theOA"orientation" vector) only needs to benon-parallel to
direction-- which valid one gets picked isirrelevant, since the arrow shaft is rotationally symmetric.
ValueErrorifstart == end(direction, and therefore pose,would be undefined).
Test plan
pytest tests/-- 172 passedantipodal-to-world-Z directions (proving the antipodal case this PR is
specifically designed to avoid actually works); coincident-points
ValueError; kwargs pass-through