mirror of
https://github.com/appgurueu/modlib.git
synced 2024-08-19 21:04:13 +02:00
Add vector.interpolate
This commit is contained in:
parent
6f0e6f459b
commit
e56e9c1207
@ -115,6 +115,12 @@ metatable.__sub = subtract
|
|||||||
metatable.__mul = multiply
|
metatable.__mul = multiply
|
||||||
metatable.__div = divide
|
metatable.__div = divide
|
||||||
|
|
||||||
|
--+ linear interpolation
|
||||||
|
--: ratio number from 0 (all the first vector) to 1 (all the second vector)
|
||||||
|
function interpolate(v, other_v, ratio)
|
||||||
|
return add(multiply(v, 1 - ratio), multiply(other_v, ratio))
|
||||||
|
end
|
||||||
|
|
||||||
function norm(v)
|
function norm(v)
|
||||||
local sum = 0
|
local sum = 0
|
||||||
for _, c in pairs(v) do
|
for _, c in pairs(v) do
|
||||||
|
Loading…
Reference in New Issue
Block a user