Skip to content

Commit

Permalink
[#294] added the get_rotmat and get_translation methods for transform…
Browse files Browse the repository at this point in the history
… objects
  • Loading branch information
YHordijk committed Aug 20, 2024
1 parent 02b19f5 commit 714f47d
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions src/tcutility/geometry.py
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,27 @@ def _build_matrix(self, R: np.ndarray = None, T: np.ndarray = None, S: np.ndarra

return np.array([[R[0, 0] * S[0], R[0, 1], R[0, 2], T[0]], [R[1, 0], R[1, 1] * S[1], R[1, 2], T[1]], [R[2, 0], R[2, 1], R[2, 2] * S[2], T[2]], [0, 0, 0, 1]])

def get_rotmat(self):
return self.M[:3, :3]

def get_translation(self):
return self.M[:3, 3]

def to_vtkTransform(self):
import vtk
vtktrans = vtk.vtkTransform()
vtktrans.PostMultiply()

angles = rotmat_to_angles(self.get_rotmat())
vtktrans.RotateX(angles[0] * 180 / np.pi)
vtktrans.RotateY(angles[1] * 180 / np.pi)
vtktrans.RotateZ(angles[2] * 180 / np.pi)

vtktrans.Translate(self.get_translation())

return vtktrans



class KabschTransform(Transform):
"""
Expand Down

0 comments on commit 714f47d

Please sign in to comment.