Skip to content

Add forward_vector_from_quaternion, direction_to_quaternion, and angle_between_directions to quaternion_utils#21

Merged
VoxleOne merged 2 commits intomainfrom
copilot/add-quaternion-utility-methods
Mar 27, 2026
Merged

Add forward_vector_from_quaternion, direction_to_quaternion, and angle_between_directions to quaternion_utils#21
VoxleOne merged 2 commits intomainfrom
copilot/add-quaternion-utility-methods

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Mar 27, 2026

Three new direction/quaternion utility functions in spinstep/utils/quaternion_utils.py.

  • forward_vector_from_quaternion(q) — Extract forward (look) direction via R.from_quat(q).apply([0, 0, -1])
  • direction_to_quaternion(direction) — Convert a 3D direction to an orientation quaternion via R.align_vectors(), with zero-vector guard
  • angle_between_directions(d1, d2) — Angular distance (radians) between two direction vectors via arccos(dot) with normalization and clamping

All three are exported from utils/__init__.py and added to __all__ in both modules. 12 new tests cover identity, roundtrip, edge cases, and mathematical correctness.

from spinstep.utils import (
    forward_vector_from_quaternion,
    direction_to_quaternion,
    angle_between_directions,
)

fwd = forward_vector_from_quaternion([0, 0, 0, 1])  # [0, 0, -1]
q = direction_to_quaternion([1, 0, 0])               # quaternion aligning -Z to +X
angle = angle_between_directions([1, 0, 0], [0, 1, 0])  # π/2

✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

…e_between_directions to quaternion_utils

Agent-Logs-Url: https://github.com/VoxleOne/SpinStep/sessions/72548df6-0009-4914-a816-0ea24ebb090e

Co-authored-by: VoxleOne <119956342+VoxleOne@users.noreply.github.com>
Copilot AI changed the title [WIP] Add new methods for quaternion utilities Add forward_vector_from_quaternion, direction_to_quaternion, and angle_between_directions to quaternion_utils Mar 27, 2026
Copilot AI requested a review from VoxleOne March 27, 2026 14:05
@VoxleOne VoxleOne marked this pull request as ready for review March 27, 2026 14:48
@VoxleOne VoxleOne merged commit a144e8b into main Mar 27, 2026
4 checks passed
@VoxleOne VoxleOne deleted the copilot/add-quaternion-utility-methods branch March 27, 2026 14:49
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.

2 participants