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

Function rotmat_to_quat

detrsmpl/utils/transforms.py:148–162  ·  view source on GitHub ↗

Convert rotation matrixs to quaternions. Args: matrix (Union[torch.Tensor, numpy.ndarray]): input shape should be (..., 3, 3). ndim of input is unlimited. Returns: Union[torch.Tensor, numpy.ndarray]: shape would be (..., 4).

(
    matrix: Union[torch.Tensor, numpy.ndarray]
)

Source from the content-addressed store, hash-verified

146
147
148def rotmat_to_quat(
149 matrix: Union[torch.Tensor, numpy.ndarray]
150) -> Union[torch.Tensor, numpy.ndarray]:
151 """Convert rotation matrixs to quaternions.
152
153 Args:
154 matrix (Union[torch.Tensor, numpy.ndarray]): input shape
155 should be (..., 3, 3). ndim of input is unlimited.
156 Returns:
157 Union[torch.Tensor, numpy.ndarray]: shape would be (..., 4).
158 """
159 if matrix.shape[-1] != 3 or matrix.shape[-2] != 3:
160 raise ValueError(f'Invalid rotation matrix shape f{matrix.shape}.')
161 t = Compose([matrix_to_quaternion])
162 return t(matrix)
163
164
165def rotmat_to_rot6d(

Callers 1

compute_lossesMethod · 0.90

Calls 1

ComposeClass · 0.70

Tested by

no test coverage detected