Skip to content

Commit

Permalink
added as_homogeneous_matrix method to LCS
Browse files Browse the repository at this point in the history
  • Loading branch information
mbwinkler committed Nov 3, 2024
1 parent 9db0093 commit 6ac88d3
Showing 1 changed file with 26 additions and 0 deletions.
26 changes: 26 additions & 0 deletions weldx/transformations/local_cs.py
Original file line number Diff line number Diff line change
Expand Up @@ -728,6 +728,32 @@ def as_rotation(self) -> Rot: # pragma: no cover
"""
return Rot.from_matrix(self.orientation.values)

def as_homogeneous_matrix(self, translation_unit: QuantityLike) -> np.ndarray:
"""Get a homogeneous transformation matrix from the coordinate system
orientation.
Returns
-------
numpy.ndarray
Numpy array representing the homogeneous transformation matrix.
"""

if self.is_time_dependent:
time_dim = self.time.shape[0]
else:
time_dim = 1

rotation = np.resize(self.orientation.data, (time_dim, 3, 3))
translation = np.resize(
self.coordinates.data.to(translation_unit).m, (time_dim, 3)
)
homogeneous_matrix = np.zeros((time_dim, 4, 4))
homogeneous_matrix[:, :3, :3] = rotation
homogeneous_matrix[:, :3, 3] = translation

return homogeneous_matrix

def _interp_time_orientation(self, time: Time) -> xr.DataArray:
"""Interpolate the orientation in time."""
if "time" not in self.orientation.dims: # don't interpolate static
Expand Down

0 comments on commit 6ac88d3

Please sign in to comment.