# Houdini VEX - Bias Lerp and Slerp

A `bias`

value tells us where, along an interpolation, to grab a value from.

If we’re interpolating between the numbers `1`

and `2`

, when `bias == 0`

, the return value is `1`

. When `bias == 1`

, the return value is `2`

. Thusly, `bias == 0.5`

would return `1.5`

.

There are two main functions to get this “return value”: `lerp`

(for all numbers and vectors) and `slerp`

(for quarternions).

Formally, to get the “middle” of interpolating between `1`

and `2`

(above example), we would write:

```
float i = lerp(1.0, 2.0, 0.5) // i == 1.5
```

### Lerp Positions

`lerp`

-ing between two point positions gives us a position that is between them.

[Above] We have two points with positions `P1`

and `P2`

. A new point is added “between” them, which is to imagine connecting them with a line, and then finding a point that is on this line.

```
vector newPointP = lerp(P1, P2, @Time)
```

Consequently, the “midpoint” is when `bias == 0.5`

.

### Slerp Rotations

`slerp`

-ing between two quarternions gives us a smooth gimbal-lock-free rotation between two orientations.

```
vector4 start = quaternion({3.34, 24.3, 4.546}); // A random orientation
vector4 end = quaternion({0, 6.54, 0}); // The "final" orientation
vector4 qrot = slerp(start, end, @Time); // Orientate over @Time
matrix xform = instance({0,0,0}, 0, 1, 0, qrot, {0,0,0});
@P = qrotate(qrot, @P); // Apply orientation to the point
```