mirror of
https://github.com/appgurueu/modlib.git
synced 2024-11-26 01:03:46 +01:00
Vector extension: Unary minus, pow
This commit is contained in:
parent
0ddc554ac0
commit
900249f8f7
@ -97,12 +97,20 @@ function combinator(f)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
function invert(v)
|
||||||
|
for key, value in pairs(v) do
|
||||||
|
v[key] = -value
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
add, add_scalar = combinator(function(a, b) return a + b end)
|
add, add_scalar = combinator(function(a, b) return a + b end)
|
||||||
subtract, subtract_scalar = combinator(function(a, b) return a - b end)
|
subtract, subtract_scalar = combinator(function(a, b) return a - b end)
|
||||||
multiply, multiply_scalar = combinator(function(a, b) return a * b end)
|
multiply, multiply_scalar = combinator(function(a, b) return a * b end)
|
||||||
divide, divide_scalar = combinator(function(a, b) return a / b end)
|
divide, divide_scalar = combinator(function(a, b) return a / b end)
|
||||||
|
pow, pow_scalar = combinator(function(a, b) return a ^ b end)
|
||||||
|
|
||||||
metatable.__add = add
|
metatable.__add = add
|
||||||
|
metatable.__unm = invert
|
||||||
metatable.__sub = subtract
|
metatable.__sub = subtract
|
||||||
metatable.__mul = multiply
|
metatable.__mul = multiply
|
||||||
metatable.__div = divide
|
metatable.__div = divide
|
||||||
|
Loading…
Reference in New Issue
Block a user