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

Function batch_rodrigues

detrsmpl/utils/geometry.py:6–21  ·  view source on GitHub ↗

Convert axis-angle representation to rotation matrix. Args: theta: size = [B, 3] Returns: Rotation matrix corresponding to the quaternion -- size = [B, 3, 3]

(theta)

Source from the content-addressed store, hash-verified

4import torchgeometry as tgm
5
6def 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
24def quat_to_rotmat(quat):

Callers 11

forwardMethod · 0.90
prepare_targetsMethod · 0.90
pose2rotmatFunction · 0.90
prepare_targetsMethod · 0.90
loss_smpl_poseMethod · 0.90
loss_smpl_poseMethod · 0.90

Calls 1

quat_to_rotmatFunction · 0.70

Tested by

no test coverage detected