Previously known as xod/core/map-range
.
#pragma XOD dirtieness disable
node {
void evaluate(Context ctx) {
auto x = getValue<input_X>(ctx);
auto sMin = getValue<input_Smin>(ctx);
auto sMax = getValue<input_Smax>(ctx);
auto tMin = getValue<input_Tmin>(ctx);
auto tMax = getValue<input_Tmax>(ctx);
auto k = (x - sMin) / (sMax - sMin);
auto xm = isnan(x) ? x : tMin + k * (tMax - tMin);
emitValue<output_OUT>(ctx, xm);
}
}
X | Smin | Smax | Tmin | Tmax | OUT |
0 | 0 | 1 | -10 | 10 | -10 |
0.5 | 0 | 1 | -10 | 10 | 0 |
25 | 0 | 1 | 0 | 10 | 250 |
-10 | 0 | 1 | 0 | 10 | -100 |
0.5 | 0 | 1 | 0 | Inf | Inf |
0.5 | 0 | 1 | -Inf | Inf | NaN |
Inf | 0 | 1 | 0 | 10 | Inf |
-Inf | 0 | 1 | 0 | 10 | -Inf |
NaN | 0 | 1 | 0 | 10 | NaN |