MCPcopy Create free account
hub / github.com/NVlabs/InstantSplat / quadmultiply

Function quadmultiply

utils/pose_utils.py:86–104  ·  view source on GitHub ↗

Multiply two quaternions together using quaternion arithmetic

(q1, q2)

Source from the content-addressed store, hash-verified

84 return w2c
85
86def quadmultiply(q1, q2):
87 """
88 Multiply two quaternions together using quaternion arithmetic
89 """
90 # Extract scalar and vector parts of the quaternions
91 w1, x1, y1, z1 = q1.unbind(dim=-1)
92 w2, x2, y2, z2 = q2.unbind(dim=-1)
93 # Calculate the quaternion product
94 result_quaternion = torch.stack(
95 [
96 w1 * w2 - x1 * x2 - y1 * y2 - z1 * z2,
97 w1 * x2 + x1 * w2 + y1 * z2 - z1 * y2,
98 w1 * y2 - x1 * z2 + y1 * w2 + z1 * x2,
99 w1 * z2 + x1 * y2 - y1 * x2 + z1 * w2,
100 ],
101 dim=-1,
102 )
103
104 return result_quaternion
105
106def _sqrt_positive_part(x: torch.Tensor) -> torch.Tensor:
107 """

Callers 1

renderFunction · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected