$30 off During Our Annual Pro Sale. View Details »

Introduction to LERP()

Pete Karl II
September 12, 2016

Introduction to LERP()

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.

Pete Karl II

September 12, 2016
Tweet

More Decks by Pete Karl II

Other Decks in Education

Transcript

  1. Hack of the Week

  2. None
  3. LINEAR INTERPOLATION

  4. LINEAR INTERPOLATION

  5. LERP()

  6. 0.0 1.0 50% = 0.5 30% = 0.3 75% =

    0.75
  7. 146.2 1701.68 50% = ??? 30% = ??? 75% =

    ???
  8. LERP(start, stop, amount)

  9. 146.2 1701.68 lerp(146.2, 1702.68, 0.5) = 924.44 LERP(start, stop, amount)

    lerp(146.2, 1702.68, 0.3) = 613.144 lerp(146.2, 1702.68, 0.75) = 1313.56
  10. None
  11. 0.0 1000.0 lerp( 0.0, 1000.0, random() ) random() returns random

    number between 0.0 and 1.0
  12. 0.0 1000.0 lerp( 0.0, 1000.0, Math.sin() ) Math.sin() given radians,

    returns sine value (between 0.0 and 1.0)
  13. None
  14. 0.0 1000.0 lerp( 0.0, 1000.0, Math.sin(???) ) Math.sin() given radians,

    returns sine value
  15. 0.0 1000.0 lerp( 0.0, 1000.0, Math.sin(time) ) Math.sin() given radians,

    returns sine value
  16. 0.0 1000.0 lerp( 0.0, 1000.0, Math.sin(time) ) Math.sin() given radians,

    returns sine value *note - Math.sin(time) formula simplified for effect
  17. Want to learn more about LERP() and how to code

    animations? https://thebookofshaders.com https://www.youtube.com/user/shiffman