fix lerp for types like vec3 by changing order, add decay

This commit is contained in:
Colby Klein 2017-03-29 05:32:04 -07:00
parent 3a18ed0f8c
commit e8228f8c8a

View File

@ -74,7 +74,17 @@ end
-- @param high value to return when `progress` is 1
-- @return number
function utils.lerp(progress, low, high)
return progress * (high - low) + low
return ((high - low) + low) * progress
end
-- Exponential decay
-- @param rate portion of the original value remaining per second
-- @param low initial value
-- @param high target value
-- @param dt time delta
-- @return number
function utils.decay(rate, low, high, dt)
return utils.lerp(1.0 - math.exp(-rate * dt), low, high)
end
--- Hermite interpolation.