数学扩展模块新增listLerp函数
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
local MATH={}for k,v in next,math do MATH[k]=v end
|
||||
|
||||
local int,ceil=math.floor,math.ceil
|
||||
local rnd=math.random
|
||||
|
||||
MATH.tau=2*math.pi
|
||||
@@ -20,10 +21,6 @@ function MATH.coin(a,b)
|
||||
end
|
||||
end
|
||||
|
||||
function MATH.lerp(s,e,t)
|
||||
return s+(e-s)*t
|
||||
end
|
||||
|
||||
function MATH.interval(v,low,high)
|
||||
if v<=low then
|
||||
return low
|
||||
@@ -34,6 +31,18 @@ function MATH.interval(v,low,high)
|
||||
end
|
||||
end
|
||||
|
||||
function MATH.lerp(s,e,t)
|
||||
return s+(e-s)*t
|
||||
end
|
||||
|
||||
do--function MATH.listLerp(list,t)
|
||||
local interval,lerp=MATH.interval,MATH.lerp
|
||||
function MATH.listLerp(list,t)
|
||||
local t2=(#list-1)*interval(t,0,1)+1
|
||||
return lerp(list[int(t2)],list[ceil(t2)],t2%1)
|
||||
end
|
||||
end
|
||||
|
||||
function MATH.expApproach(a,b,k)
|
||||
return b+(a-b)*2.718281828459045^-k
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user