fix lerp for vec3, update tests for broken lerp case

This commit is contained in:
Colby Klein 2017-05-19 09:49:07 -07:00
parent f6ad9335cc
commit 0ff68c69fd
2 changed files with 6 additions and 1 deletions

View File

@ -74,7 +74,7 @@ end
-- @param progress (0-1)
-- @return number
function utils.lerp(low, high, progress)
return (1 - progress) * low + progress * high
return low * (1 - progress) + high * progress
end
--- Exponential decay

View File

@ -16,6 +16,11 @@ describe("utils:", function()
local b = vec3(1, 1, 1)
local c = vec3(0.5, 0.5, 0.5)
assert.is.equal(utils.lerp(a, b, 0.5), c)
a = vec3(5, 5, 5)
b = vec3(0, 0, 0)
c = vec3(2.5, 2.5, 2.5)
assert.is.equal(utils.lerp(a, b, 0.5), c)
end)
it("decays exponentially", function()