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

Function build_rotation_4d

utils/general_utils.py:113–133  ·  view source on GitHub ↗
(l, r)

Source from the content-addressed store, hash-verified

111 return L
112
113def build_rotation_4d(l, r):
114 l_norm = torch.norm(l, dim=-1, keepdim=True)
115 r_norm = torch.norm(r, dim=-1, keepdim=True)
116
117 q_l = l / l_norm
118 q_r = r / r_norm
119
120 a, b, c, d = q_l.unbind(-1)
121 p, q, r, s = q_r.unbind(-1)
122
123 M_l = torch.stack([a,-b,-c,-d,
124 b, a,-d, c,
125 c, d, a,-b,
126 d,-c, b, a]).view(4,4,-1).permute(2,0,1)
127 M_r = torch.stack([ p, q, r, s,
128 -q, p,-s, r,
129 -r, s, p,-q,
130 -s,-r, q, p]).view(4,4,-1).permute(2,0,1)
131 A = M_l @ M_r
132 A = A.flip(1,2)
133 return A
134
135def build_scaling_rotation_4d(s, l, r):
136 L = torch.zeros((s.shape[0], 4, 4), dtype=torch.float, device="cuda")

Callers 2

densify_and_splitMethod · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected