Convert axis-angle representation to rotation matrix. Args: theta: size = [B, 3] Returns: Rotation matrix corresponding to the quaternion -- size = [B, 3, 3]
(theta)
| 4 | import torchgeometry as tgm |
| 5 | |
| 6 | def batch_rodrigues(theta): |
| 7 | """Convert axis-angle representation to rotation matrix. |
| 8 | |
| 9 | Args: |
| 10 | theta: size = [B, 3] |
| 11 | Returns: |
| 12 | Rotation matrix corresponding to the quaternion -- size = [B, 3, 3] |
| 13 | """ |
| 14 | l1norm = torch.norm(theta + 1e-8, p=2, dim=1) |
| 15 | angle = torch.unsqueeze(l1norm, -1) |
| 16 | normalized = torch.div(theta, angle) |
| 17 | angle = angle * 0.5 |
| 18 | v_cos = torch.cos(angle) |
| 19 | v_sin = torch.sin(angle) |
| 20 | quat = torch.cat([v_cos, v_sin * normalized], dim=1) |
| 21 | return quat_to_rotmat(quat) |
| 22 | |
| 23 | |
| 24 | def quat_to_rotmat(quat): |
no test coverage detected