sábado, 26 de março de 2016

BP Compendium: Lerp

Lerp


Lerp is an abbreviation of "Linear Interpolation". The function generates a value within a range of two specified values, based on the value of the "Alpha" parameter.

Input

  • A: Float value that represents the lowest value that can be returned.
  • B: Float value that represents the highest value that can be returned.
  • Alpha: Float value between 0 and 1. If Alpha is 0 return the lowest value and if alpha is 1 return the highest value.

Output

  • Return Value: Float value between A and B depending on the value of alpha.


Example Usage

Imagine a race that occurs along the X axis. The race starts at the position X = 1500 and ends at the position X = 9500. If we use the "Lerp" function passing as parameters A = 1500, B = 9500 and Alpha = 0.5, the result is the position 5500 representing the middle of the race.



The image below shows a function that takes a value between 0 and 1 that indicates how much has been completed of the race and returns the equivalent X position.

Click to enlarge