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

Function quat_to_rotmat

detrsmpl/utils/transforms.py:204–219  ·  view source on GitHub ↗

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

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

Source from the content-addressed store, hash-verified

202
203
204def quat_to_rotmat(
205 quaternions: Union[torch.Tensor, numpy.ndarray]
206) -> Union[torch.Tensor, numpy.ndarray]:
207 """Convert quaternions to rotation matrixs.
208
209 Args:
210 quaternions (Union[torch.Tensor, numpy.ndarray]): input shape
211 should be (..., 3). ndim of input is unlimited.
212 Returns:
213 Union[torch.Tensor, numpy.ndarray]: shape would be (..., 3, 3).
214 """
215 if quaternions.shape[-1] != 4:
216 raise ValueError(
217 f'Invalid input quaternions shape f{quaternions.shape}.')
218 t = Compose([quaternion_to_matrix])
219 return t(quaternions)
220
221
222def rot6d_to_rotmat(

Callers 1

forwardMethod · 0.90

Calls 1

ComposeClass · 0.70

Tested by

no test coverage detected