Tips for creating Animations section - lerp method

im really bad at maths.

Below is an explanation im struggling to grasp with the tutorials’ instruction, and example, of how the lerp method works.

let value = lerp(20, 250, 0.2); // value is 66

In the code example above, the lerp() function is used to calculate a number that is 20 percent (0.2) from 20 towards 250. The value of the variable value is equal to 66.

Can someone explain how 20 percent is equal to 66 in this case?

You have a range of numbers that starts with 20 (not with zero) and goes up to 250.
You need to find 20% within this range.
The math behind this is:
250 - 20 = 230 // this is the true length of the range
230 * 20 / 100 = 46 // this is 20% of 230
46 + 20 = 66 // remember, the range doesn’t start from 0

ah yes starting the range from 0 was my problem was i did have 46% !
Thanks alot for your help

1 Like