MCPcopy Create free account
hub / github.com/MotrixLab/AiOS / rotmat_to_aa

Function rotmat_to_aa

detrsmpl/utils/transforms.py:351–368  ·  view source on GitHub ↗

Convert rotation matrixs to axis angles. Args: matrix (Union[torch.Tensor, numpy.ndarray]): input shape should be (..., 3, 3). ndim of input is unlimited. convention (str, optional): Convention string of three letters from {“x”, “y”, and “z”}. Def

(
        matrix: Union[torch.Tensor, numpy.ndarray],
        convention: str = 'xyz')

Source from the content-addressed store, hash-verified

349
350
351def rotmat_to_aa(
352 matrix: Union[torch.Tensor, numpy.ndarray],
353 convention: str = 'xyz') -> Union[torch.Tensor, numpy.ndarray]:
354 """Convert rotation matrixs to axis angles.
355
356 Args:
357 matrix (Union[torch.Tensor, numpy.ndarray]): input shape
358 should be (..., 3, 3). ndim of input is unlimited.
359 convention (str, optional): Convention string of three letters
360 from {“x”, “y”, and “z”}. Defaults to 'xyz'.
361
362 Returns:
363 Union[torch.Tensor, numpy.ndarray]: shape would be (..., 3).
364 """
365 if matrix.shape[-1] != 3 or matrix.shape[-2] != 3:
366 raise ValueError(f'Invalid rotation matrix shape f{matrix.shape}.')
367 t = Compose([matrix_to_quaternion, quaternion_to_axis_angle])
368 return t(matrix)
369
370
371def quat_to_ee(quaternions: Union[torch.Tensor, numpy.ndarray],

Callers 8

__call__Method · 0.90
__call__Method · 0.90
_rotate_smpl_poseFunction · 0.90
forwardMethod · 0.90
forwardMethod · 0.90

Calls 1

ComposeClass · 0.70

Tested by

no test coverage detected