mirror of
https://github.com/appgurueu/modlib.git
synced 2024-11-22 15:23:48 +01:00
Quaternion: Add conjugate and invert
This commit is contained in:
parent
4400cdeed9
commit
afed4793cb
@ -16,6 +16,19 @@ function normalize(self)
|
||||
return res
|
||||
end
|
||||
|
||||
function conjugate(self)
|
||||
return {
|
||||
-self[1],
|
||||
-self[2],
|
||||
-self[3],
|
||||
self[4]
|
||||
}
|
||||
end
|
||||
|
||||
function inverse(self)
|
||||
return modlib.vector.divide_scalar(conjugate(self), self[1] ^ 2 + self[2] ^ 2 + self[3] ^ 2 + self[4] ^ 2)
|
||||
end
|
||||
|
||||
function negate(self)
|
||||
for key, value in pairs(self) do
|
||||
self[key] = -value
|
||||
|
Loading…
Reference in New Issue
Block a user