ratio

koadrobot/aritmatics/ratio

Ratio = (Sstop-Sstart) / (TStop-TStart) Sdiff : +..+..--..-- Tdiff : +..--..+..-- Ratio=+..--..--..+
ratio
@/ratio
Ratio = (Sstop-Sstart) / (TStop-TStart) Sdiff : +..+..--..-- Tdiff : +..--..+..-- Ratio=+..--..--..+
Sstartnumber
Source range lower bound
Sstopnumber
Source range upper bound
Tstartnumber
Target range lower bound
Tstopnumber
Tartger range upper bound
ratio
OUT
Sstart
Sstop
Tstart
Tstop
OUTnumber
To use the node in your project you should have the koadrobot/aritmatics library installed. Use the “File → Add Library” menu item in XOD IDE if you don’t have it yet. See Using libraries for more info.

C++ implementation

#pragma XOD dirtieness disable

struct State {
};

{{ GENERATED_CODE }}

void evaluate(Context ctx) {
    Number Sstart = getValue<input_Sstart>(ctx);
    Number Sstop = getValue<input_Sstop>(ctx);
    Number Tstart = getValue<input_Tstart>(ctx);
    Number Tstop = getValue<input_Tstop>(ctx);
    Number outX = (Sstop-Sstart)/(Tstop-Tstart);
    emitValue<output_OUT>(ctx, outX);
}

Tabular tests

SstartSstopTstartTstopOUT
0100101
100010-1
010100-1
1001001
0-10010-1
-1000101
0-101001
-100100-1
0100-10-1
1000-101
010-1001
100-100-1
0-100-101
-1000-10-1
0-10-100-1
-100-1001
01000Inf
000100
0000NaN