from databpy.utils import lerp
lerp(1, 2, 0.5)
lerp(3, 7, 0.2)
lerp([1, 2, 3], [4, 5, 6], 0.5)array([2.5, 3.5, 4.5])
Linearly interpolate between two values.
| Name | Type | Description | Default |
|---|---|---|---|
| a | npt.ArrayLike | The starting value(s). | required |
| b | npt.ArrayLike | The ending value(s). | required |
| t | float | npt.ArrayLike | The interpolation parameter. Default is 0.5. | 0.5 |
| Name | Type | Description |
|---|---|---|
| np.ndarray | The interpolated value(s). |
Computes a + (b - a) * t, so t = 0 gives a and t = 1 gives b. Values of t outside [0, 1] extrapolate beyond a and b.