Skip to content

Lookup (4 pt)

Interpolates between four configured (xs[i], ys[i]) breakpoints and clamps below the first and above the last.

For xs[i] <= u <= xs[i+1], y = ys[i] + (u - xs[i]) * (ys[i+1] - ys[i]) / (xs[i+1] - xs[i]). Values at or below xs[0] return ys[0]; values above xs[3] return ys[3]. A non-increasing segment returns its left endpoint instead of dividing by zero.

Direction Name Type
Input u T
Output y T
Name Type Default Meaning
T type (default f64) f64 Float scalar type
xs [T; 4] [0.0, 1.0, 2.0, 3.0] Input breakpoints
ys [T; 4] [0.0, 1.0, 2.0, 3.0] Output values at the breakpoints

T is f32 or f64, never an array, since the block compares its input against the breakpoints. Use strictly increasing xs for normal interpolation.

With xs = [0.0, 1.0, 2.0, 3.0] and ys = [0.0, 2.0, 2.0, 6.0], inputs -1, 0.5, 2.5, 4 produce 0, 1, 4, 6.