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]
)
| 202 | |
| 203 | |
| 204 | def 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 | |
| 222 | def rot6d_to_rotmat( |