Clips an input value so that the value is always inside a [MIN, MAX] range.
clip
@/clip
Clips an input value so that the value is always inside a [MIN, MAX] range.
OUTnumber
The result. Equals to `X` if it is already in the range, otherwise, its `Xc` rounded to a nearest bound: `MIN` or `MAX`.
#pragma XOD dirtieness disable
node {
void evaluate(Context ctx) {
auto x = getValue<input_X>(ctx);
auto rMin = getValue<input_MIN>(ctx);
auto rMax = getValue<input_MAX>(ctx);
auto xc =
x > rMax ? rMax :
x < rMin ? rMin : x;
emitValue<output_OUT>(ctx, xc);
}
}
| X | MIN | MAX | OUT |
| 0 | 0 | 0 | 0 |
| 1 | 0 | 0 | 0 |
| -100 | -10.5 | 10.5 | -10.5 |
| 100 | -10.5 | 10.5 | 10.5 |
| 5.74 | -10.5 | 10.5 | 5.74 |
| Inf | -10.5 | 10.5 | 10.5 |
| -Inf | -10.5 | 10.5 | -10.5 |
| Inf | -Inf | Inf | Inf |
| -Inf | -Inf | Inf | -Inf |
| NaN | -10.5 | 10.5 | NaN |
| 50 | NaN | NaN | 50 |