Skip to content

Commit

Permalink
Euler backward test
Browse files Browse the repository at this point in the history
  • Loading branch information
Romain BRÉGIER committed Apr 19, 2024
1 parent 4b8740d commit d5eabcc
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion test/test_euler.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,16 @@ def test_euler_rotmat_consistency(self):
else:
self.assertTrue(all([torch.all(angle > -np.pi) and torch.all(angle <= np.pi) for angle in angles]))
q1 = roma.euler_to_rotmat(convention, angles, degrees=degrees)
self.assertTrue(torch.all(roma.rotmat_geodesic_distance(q, q1) < 1e-6))
self.assertTrue(torch.all(roma.rotmat_geodesic_distance(q, q1) < 1e-6))

def test_euler_backward(self):
for intrinsics in (True, False):
for convention in ["".join(permutation) for permutation in itertools.permutations('xyz')] + ["xyx", "xzx", "yxy", "yzy", "zxz", "zyz"]:
if intrinsics:
convention = convention.upper()
rotvec = torch.randn(3, requires_grad=True)
angles = roma.rotvec_to_euler('xyz', rotvec)
sum(angles).backward()

if __name__ == "__main__":
unittest.main()

0 comments on commit d5eabcc

Please sign in to comment.