MCPcopy Create free account
hub / github.com/MotrixLab/ViMoGen / rot6d_to_mat3x3

Function rot6d_to_mat3x3

motion_rep/rotation_transform.py:9–23  ·  view source on GitHub ↗

Convert 6d rotation representation to 3x3 rotation matrix. Shape: - Input: :Torch:`(N, 6)` - Output: :Torch:`(N, 3, 3)`

(rot6d)

Source from the content-addressed store, hash-verified

7 return R[..., :, :2].reshape(R.shape[0], 6)
8
9def 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
25def axis_angle_to_rot6d(angle_axis):
26 """Convert 3d vector of axis-angle rotation to 6d rotation representation.

Callers 2

motion_visFunction · 0.90
motion_rep_to_SMPLFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected