This was one of a weekly series I did on technical topics. This 5-minute introduction to linear interpolation was meant to show how code could feel natural.
Hack ofthe Week
View Slide
LINEAR INTERPOLATION
LERP()
0.0 1.050% = 0.530% = 0.375% = 0.75
146.2 1701.6850% = ???30% = ???75% = ???
LERP(start, stop, amount)
146.2 1701.68lerp(146.2, 1702.68, 0.5) = 924.44LERP(start, stop, amount)lerp(146.2, 1702.68, 0.3) = 613.144lerp(146.2, 1702.68, 0.75) = 1313.56
0.0 1000.0lerp( 0.0, 1000.0, random() )random()returns random number between 0.0 and 1.0
0.0 1000.0lerp( 0.0, 1000.0, Math.sin() )Math.sin()given radians, returns sine value (between 0.0 and 1.0)
0.0 1000.0lerp( 0.0, 1000.0, Math.sin(???) )Math.sin()given radians, returns sine value
0.0 1000.0lerp( 0.0, 1000.0, Math.sin(time) )Math.sin()given radians, returns sine value
0.0 1000.0lerp( 0.0, 1000.0, Math.sin(time) )Math.sin()given radians, returns sine value*note - Math.sin(time) formula simplified for effect
Want to learn more about LERP() andhow to code animations?https://thebookofshaders.com https://www.youtube.com/user/shiffman