Skip to content

Commit

Permalink
rotation
Browse files Browse the repository at this point in the history
  • Loading branch information
0x00b1 committed Apr 8, 2024
1 parent ab3c77d commit de3de68
Showing 1 changed file with 4 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -39,20 +39,10 @@ def compose_rotation_quaternion(
)

for j in range(max(input.shape[0], other.shape[0])):
a = input[j, 0]
b = input[j, 1]
d = input[j, 2]
s = input[j, 3]

t = other[j, 0]
u = other[j, 1]
c = other[j, 2]
w = other[j, 3]

output[j, 0] = s * t + w * a + b * c - d * u
output[j, 1] = s * u + w * b + d * t - a * c
output[j, 2] = s * c + w * d + a * u - b * t
output[j, 3] = s * w - a * t - b * u - d * c
output[j, 0] = input[j, 3] * other[j, 0] + other[j, 3] * input[j, 0] + input[j, 1] * other[j, 2] - input[j, 2] * other[j, 1] # fmt: skip
output[j, 1] = input[j, 3] * other[j, 1] + other[j, 3] * input[j, 1] + input[j, 2] * other[j, 0] - input[j, 0] * other[j, 2] # fmt: skip
output[j, 2] = input[j, 3] * other[j, 2] + other[j, 3] * input[j, 2] + input[j, 0] * other[j, 1] - input[j, 1] * other[j, 0] # fmt: skip
output[j, 3] = input[j, 3] * other[j, 3] - input[j, 0] * other[j, 0] - input[j, 1] * other[j, 1] - input[j, 2] * other[j, 2] # fmt: skip

x = torch.sqrt(output[j, 0] ** 2.0 + output[j, 1] ** 2.0 + output[j, 2] ** 2.0 + output[j, 3] ** 2.0) # fmt: skip

Expand Down

0 comments on commit de3de68

Please sign in to comment.