Hello, I am only asking a very small code which is:
All I am asking is what does this mean?
Hello, I am only asking a very small code which is:
All I am asking is what does this mean?
this mean that you is making linear interpolation, which is a smoothly blending between two values.
a
and b
represent the starting and ending values, respectively.
t
is a value between 0 and 1 that controls the interpolation between a
and b
.
(adding on)
…So for example, t = 0.5
would represent the halfway point between a
and b
, t = 0.25
would represent going a quarter way from a
to b
, t = 0.75
being three quarters of the way from a
to b
, etc.
Also that code is wrong. The function should actually do
return a + (b - a) * t
I’m not sure where you got that 1
from.
a
is your starting position when lerping.
(b - a)
Is the point of difference between b, which is the position relative from a.
t works in percentages, ranging from very small fractions , all the way up to 1, which is a complete 100%. t
will multiply (b - a)
into a percentage of the way to b
, which is how we get our transition effect.
For Example:
a = 10
b = 100
According to (b - a)
, (100 - 10)
would equal 90
relative to the position a
is in, but when t multiplies that number to 0.01 (1% of the way)
, a
is now 10.9 due to that interpolation.
It is the same as something asking to find the percentage of the number, which in this case, its same as asking for 1% of 90
.
So in math form, your interpolation would look like this:
10 + 1/100(90) = 10.9
Very good explanation! Thanks!
This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.