Lerp, short for linear interpolation, is a mathematical technique for producing intermediate states between a start and an endpoint. It is related to tweening.
For a single variable, we can define
function lerp(a, b, t)
return a * (1-t) + (b*t)
end
By definition, for all implementations of lerp:
lerp(a, b, 0) == a
lerp(a, b, 1) == b
lerp(a, b, x) == lerp(b, a, 1-x)
Two roblox types have a lerp method:
Vector3.Lerp — interpolates all three components as above
CFrame.lerp — uses quaternion slerp to interpolate orientations, and linear interpolation to interpolate positions
For which the previous identities still hold:
vecA:Lerp(vecB, 0) == vecA
vecA:Lerp(vecB, 1) == vecB
cfA:lerp(cfB, 0) == cfA
cfA:lerp(cfB, 1) == cfB
2 comments
Sorry, but I can't understand what is the use of it. You are just giving me the "How" to use it, but I need the "What" for it's use?
I'm not saying your equation is wrong, but there's another one that also works. a + (b - a)*t