MCPcopy Create free account
hub / github.com/OpenImagingLab/4DSloMo / build_rotation

Function build_rotation

utils/general_utils.py:79–100  ·  view source on GitHub ↗
(r)

Source from the content-addressed store, hash-verified

77 return strip_lowerdiag(sym)
78
79def 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
102def build_scaling_rotation(s, r):
103 L = torch.zeros((s.shape[0], 3, 3), dtype=torch.float, device="cuda")

Callers 2

densify_and_splitMethod · 0.90
build_scaling_rotationFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected