Skip to content

Commit

Permalink
Issue #72: Use ravel to defend against different translation vector i…
Browse files Browse the repository at this point in the history
…nputs in a consistent faashion.
  • Loading branch information
MattClarkson committed Apr 12, 2024
1 parent d420a02 commit 24cbed0
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 additions & 4 deletions sksurgerycore/transforms/matrix.py
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,8 @@ def construct_rotm_from_euler(


def construct_rigid_transformation(rot_m, trans_v):
"""Construct a 4x4 rigid-body transformation from a 3x3 rotation matrix and
"""
Construct a 4x4 rigid-body transformation from a 3x3 rotation matrix and
a 3x1 vector as translation
:param rot_m: 3x3 rotation matrix, numpy array
Expand All @@ -148,8 +149,14 @@ def construct_rigid_transformation(rot_m, trans_v):
for j in range(3):
rigid_transformation[i][j] = rot_m[i][j]

rigid_transformation[0][3] = trans_v[0]
rigid_transformation[1][3] = trans_v[1]
rigid_transformation[2][3] = trans_v[2]
# While the specification is [3x1] which implies ndarray, the users
# may also pass in array (3,), ndarray (3, 1) or ndarray (1, 3).
# So, this will flatten all of them to the same array-like shape.
# In keeping with the rotation matrix, no range checking.
t_v = np.ravel(trans_v)

rigid_transformation[0][3] = t_v[0]
rigid_transformation[1][3] = t_v[1]
rigid_transformation[2][3] = t_v[2]

return rigid_transformation

0 comments on commit 24cbed0

Please sign in to comment.