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

Function rot6d_to_rotmat

detrsmpl/utils/geometry.py:53–72  ·  view source on GitHub ↗

Convert 6D rotation representation to 3x3 rotation matrix. Based on Zhou et al., "On the Continuity of Rotation Representations in Neural Networks", CVPR 2019 Input: (B,6) Batch of 6-D rotation representations Output: (B,3,3) Batch of corresponding rotation matrices

(x)

Source from the content-addressed store, hash-verified

51
52
53def rot6d_to_rotmat(x):
54 """Convert 6D rotation representation to 3x3 rotation matrix.
55
56 Based on Zhou et al., "On the Continuity of Rotation
57 Representations in Neural Networks", CVPR 2019
58 Input:
59 (B,6) Batch of 6-D rotation representations
60 Output:
61 (B,3,3) Batch of corresponding rotation matrices
62 """
63 if isinstance(x, torch.Tensor):
64 x = x.reshape(-1, 3, 2)
65 elif isinstance(x, np.ndarray):
66 x = x.view(-1, 3, 2)
67 a1 = x[:, :, 0]
68 a2 = x[:, :, 1]
69 b1 = F.normalize(a1)
70 b2 = F.normalize(a2 - torch.einsum('bi,bi->b', b1, a2).unsqueeze(-1) * b1)
71 b3 = torch.cross(b1, b2)
72 return torch.stack((b1, b2, b3), dim=-1)
73
74def rot6d_to_axis_angle(x):
75 batch_size = x.shape[0]

Callers 8

_report_ihmrMethod · 0.90
_report_ihmrMethod · 0.90
__call__Method · 0.90
forwardMethod · 0.90
forwardMethod · 0.90
regress_smplMethod · 0.90
forwardMethod · 0.90
forwardMethod · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected