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

Function rotation_matrix_to_angle_axis

detrsmpl/utils/geometry.py:90–116  ·  view source on GitHub ↗

This function is borrowed from https://github.com/kornia/kornia Convert 3x4 rotation matrix to Rodrigues vector Args: rotation_matrix (Tensor): rotation matrix. Returns: Tensor: Rodrigues vector transformation. Shape: - Input: :math:`(N, 3, 4)` -

(rotation_matrix)

Source from the content-addressed store, hash-verified

88 return axis_angle
89
90def rotation_matrix_to_angle_axis(rotation_matrix):
91 """
92 This function is borrowed from https://github.com/kornia/kornia
93 Convert 3x4 rotation matrix to Rodrigues vector
94 Args:
95 rotation_matrix (Tensor): rotation matrix.
96 Returns:
97 Tensor: Rodrigues vector transformation.
98 Shape:
99 - Input: :math:`(N, 3, 4)`
100 - Output: :math:`(N, 3)`
101 Example:
102 >>> input = torch.rand(2, 3, 4) # Nx3x4
103 >>> output = tgm.rotation_matrix_to_angle_axis(input) # Nx3
104 """
105 if rotation_matrix.shape[1:] == (3, 3):
106 rot_mat = rotation_matrix.reshape(-1, 3, 3)
107 hom = torch.tensor([0, 0, 1],
108 dtype=torch.float32,
109 device=rotation_matrix.device)
110 hom = hom.reshape(1, 3, 1).expand(rot_mat.shape[0], -1, -1)
111 rotation_matrix = torch.cat([rot_mat, hom], dim=-1)
112
113 quaternion = rotation_matrix_to_quaternion(rotation_matrix)
114 aa = quaternion_to_angle_axis(quaternion)
115 aa[torch.isnan(aa)] = 0.0
116 return aa
117
118
119def quaternion_to_angle_axis(quaternion: torch.Tensor) -> torch.Tensor:

Callers 2

run_registrationMethod · 0.90
make_fake_dataMethod · 0.90

Calls 2

quaternion_to_angle_axisFunction · 0.85

Tested by

no test coverage detected