Skip to content

Refactor rotation matrix alignment - #342

Open
Ryukon07 wants to merge 1 commit into
SWIFTSIM:masterfrom
Ryukon07:refactor/rotation-align-vectors
Open

Refactor rotation matrix alignment#342
Ryukon07 wants to merge 1 commit into
SWIFTSIM:masterfrom
Ryukon07:refactor/rotation-align-vectors

Conversation

@Ryukon07

@Ryukon07 Ryukon07 commented Sep 5, 2026

Copy link
Copy Markdown

rotation_matrix_from_vector currently implements vector alignment with manual cross-product algebra. This replaces that implementation with SciPy's existing Rotation.align_vectors utility while preserving the package's optional-SciPy import behavior.

The focused tests cover vectors both parallel and antiparallel to each target axis, require a proper rotation with determinant +1, and verify the missing-SciPy error.

Validation:

  • pytest -q tests/test_rotation.py (3 passed)
  • ruff check .
  • ruff format --check .
  • python -m numpydoc lint swiftsimio/optional_packages.py swiftsimio/visualisation/rotation.py tests/test_rotation.py
  • git diff --check
  • 30,000 deterministic rotations: maximum alignment error 6.699e-14, orthogonality error 1.221e-15, determinant error 1.554e-15

The broader rotation/visualisation selection was intermittent locally: its parallel volume-render exact-equality case failed in some Python 3.12 and 3.14 runs and passed in later default-thread and single-thread reruns. Direct probes using both the old and new rotation implementations also produced exact render matches, so I could not establish a deterministic regression.

Closes #309

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.

Refactor rotation_matrix_from_vector

1 participant