-
Notifications
You must be signed in to change notification settings - Fork 15
Open
Description
Default implementation looks buggy in version 2.0.0:
import vmath
# Correct implementation
func mult(q, p: Quat): Quat =
result.x = p.x * q.w + p.y * q.z - p.z * q.y + p.w * q.x
result.y = -(p.x * q.z) + p.y * q.w + p.z * q.x + p.w * q.y
result.z = p.x * q.y - p.y * q.x + p.z * q.w + p.w * q.z
result.w = -(p.x * q.x) - p.y * q.y - p.z * q.z + p.w * q.w
let
q1 = quat(1, 2, 3, 4)
q2 = quat(5, 6, 7, 8)
echo q1 * q2 # vec4(5.0, 12.0, 21.0, 32.0)
echo mult(q1, q2) # vec4(32.0, 32.0, 56.0, -6.0)
Metadata
Metadata
Assignees
Labels
No labels