Convert 6d rotation representation to 3x3 rotation matrix. Shape: - Input: :Torch:`(N, 6)` - Output: :Torch:`(N, 3, 3)`
(rot6d)
| 7 | return R[..., :, :2].reshape(R.shape[0], 6) |
| 8 | |
| 9 | def rot6d_to_mat3x3(rot6d): |
| 10 | """ |
| 11 | Convert 6d rotation representation to 3x3 rotation matrix. |
| 12 | Shape: |
| 13 | - Input: :Torch:`(N, 6)` |
| 14 | - Output: :Torch:`(N, 3, 3)` |
| 15 | """ |
| 16 | rot6d = rot6d.view(-1, 3, 2) |
| 17 | a1 = rot6d[:, :, 0] |
| 18 | a2 = rot6d[:, :, 1] |
| 19 | b1 = F.normalize(a1) |
| 20 | b2 = F.normalize(a2 - torch.einsum('bi,bi->b', b1, a2).unsqueeze(-1) * b1) |
| 21 | b3 = torch.cross(b1, b2, dim=-1) |
| 22 | rot_mat = torch.stack((b1, b2, b3), dim=-1) # 3x3 rotation matrix |
| 23 | return rot_mat |
| 24 | |
| 25 | def axis_angle_to_rot6d(angle_axis): |
| 26 | """Convert 3d vector of axis-angle rotation to 6d rotation representation. |
no outgoing calls
no test coverage detected