mirror of
https://github.com/appgurueu/modlib.git
synced 2024-11-22 07:13:45 +01:00
Fix quaternion multiplication
This commit is contained in:
parent
3fc0808b18
commit
912f2f01a0
@ -24,11 +24,12 @@ function from_euler_rotation_deg(rotation)
|
|||||||
end
|
end
|
||||||
|
|
||||||
function multiply(self, other)
|
function multiply(self, other)
|
||||||
return {
|
local X, Y, Z, W = unpack(self)
|
||||||
other[1] * self[1] - other[2] * self[2] - other[3] * self[3] - other[4] * self[4],
|
return normalize{
|
||||||
other[1] * self[2] + other[2] * self[1] - other[3] * self[4] + other[4] * self[3],
|
(other[4] * X) + (other[1] * W) + (other[2] * Z) - (other[3] * Y);
|
||||||
other[1] * self[3] + other[2] * self[4] + other[3] * self[1] - other[4] * self[2],
|
(other[4] * Y) + (other[2] * W) + (other[3] * X) - (other[1] * Z);
|
||||||
other[1] * self[4] - other[2] * self[3] + other[3] * self[2] + other[4] * self[1]
|
(other[4] * Z) + (other[3] * W) + (other[1] * Y) - (other[2] * X);
|
||||||
|
(other[4] * W) - (other[1] * X) - (other[2] * Y) - (other[3] * Z);
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user