Add utils.smoothstep (smooth hermite interpolation)
This commit is contained in:
parent
871c9246d0
commit
6f050bd1c8
@ -12,6 +12,11 @@ function utils.lerp(v, l, h)
|
||||
return v * (h - l) + l
|
||||
end
|
||||
|
||||
function utils.smoothstep(v, l, h)
|
||||
local t = utils.clamp((v - l) / (h - l), 0.0, 1.0)
|
||||
return t * t * (3.0 - 2.0 * t)
|
||||
end
|
||||
|
||||
function utils.round(v, precision)
|
||||
if precision then return utils.round(v / precision) * precision end
|
||||
return v >= 0 and math.floor(v+0.5) or math.ceil(v-0.5)
|
||||
|
Loading…
x
Reference in New Issue
Block a user