(r)
| 77 | return strip_lowerdiag(sym) |
| 78 | |
| 79 | def build_rotation(r): |
| 80 | norm = torch.sqrt(r[:,0]*r[:,0] + r[:,1]*r[:,1] + r[:,2]*r[:,2] + r[:,3]*r[:,3]) |
| 81 | |
| 82 | q = r / norm[:, None] |
| 83 | |
| 84 | R = torch.zeros((q.size(0), 3, 3), device='cuda') |
| 85 | |
| 86 | r = q[:, 0] |
| 87 | x = q[:, 1] |
| 88 | y = q[:, 2] |
| 89 | z = q[:, 3] |
| 90 | |
| 91 | R[:, 0, 0] = 1 - 2 * (y*y + z*z) |
| 92 | R[:, 0, 1] = 2 * (x*y - r*z) |
| 93 | R[:, 0, 2] = 2 * (x*z + r*y) |
| 94 | R[:, 1, 0] = 2 * (x*y + r*z) |
| 95 | R[:, 1, 1] = 1 - 2 * (x*x + z*z) |
| 96 | R[:, 1, 2] = 2 * (y*z - r*x) |
| 97 | R[:, 2, 0] = 2 * (x*z - r*y) |
| 98 | R[:, 2, 1] = 2 * (y*z + r*x) |
| 99 | R[:, 2, 2] = 1 - 2 * (x*x + y*y) |
| 100 | return R |
| 101 | |
| 102 | def build_scaling_rotation(s, r): |
| 103 | L = torch.zeros((s.shape[0], 3, 3), dtype=torch.float, device="cuda") |
no outgoing calls
no test coverage detected