Skip to content

refactor: ♻️ Use the shared rot_mat_22 helper for 2D rotations - #156

Open
Tektrix wants to merge 1 commit into
ShisatoYano:mainfrom
Tektrix:refactor/125-shared-rotation-helper
Open

Tektrix wants to merge 1 commit into
ShisatoYano:mainfrom
Tektrix:refactor/125-shared-rotation-helper

Conversation

@Tektrix

@Tektrix Tektrix commented Oct 27, 2026

Copy link
Copy Markdown

Closes #125.

Overview

  • XYArray.homogeneous_transformation() now uses rot_mat_22 instead of a hand-written rotation matrix, and adds the translation with plain broadcasting (+ np.array([[x], [y]])) instead of np.ones(shape) * [[x], [y]].
  • InformedRrtStarPathPlanner.sample_informed() now uses rot_mat_22(theta) for its rotation matrix.
  • rot_mat_22 gets a docstring in the same style as hom_mat_33.

Both files load matrix_lib with the same sys.path.append(...) pattern the existing code uses. The other -sin matches in src/components (cubic spline course, L-shape fitting) are projections, not rotation matrices, so I left them as they are. Behavior is unchanged.

How I confirmed it works

  • rot_mat_22 builds the same matrix as the code it replaces, and broadcasting a 2x1 column gives the same result as multiplying it with np.ones first.
  • The changed code is covered by the existing tests: test_xy_array.py (including test_homogeneous_transformation), test_matrix_lib.py and test_informed_rrt_star_path_planning.py, which run in GitHub Actions on this PR.

Replace the hand-written rotation matrices in XYArray.homogeneous_transformation()
and InformedRrtStarPathPlanner.sample_informed() with rot_mat_22, add the translation
in XYArray with plain broadcasting, and add a docstring to rot_mat_22.
Behavior is unchanged.

Closes ShisatoYano#125
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.

Use the shared rotation and transformation helpers

1 participant