Umeer’s Blog

Animation Programming

Linear Interpolation (Lerp)

This is just a quick exploration into Lerp and the Math behind it to learn the basic concepts.

 

Formula: 

Vector a (Initial), Vector b (Target), float t (ratio from 0 to 1)

Resulting Vector = (a.x+(b.x - a.x) * t,

                                a.y+(b.y - a.y) * t,

                                a.z+(b.z - a.z) * t)

 

  • b.x - a.x returns the difference between the two components
  • t scales the result of b.x - a.x between 0 and the result
    • (4-1) = 3 so t will scale it from 0 to 3
  • adding a.x at the end makes it the starting point when t = 0 and at t = 1, the x will be equal to b.x

 

Here's an interactive example:

www.geogebra.org