8 lines
407 B
Plaintext
8 lines
407 B
Plaintext
// LinearInterp: the value at X on the straight line through (X0, Y0) and
|
|
// (X1, Y1). X may lie outside [X0, X1]: that is extrapolation, and the line
|
|
// carries on. The REQUIRE names the difference the division divides by.
|
|
FUNCTION LinearInterp(X0 : FLOAT, Y0 : FLOAT, X1 : FLOAT, Y1 : FLOAT, X : FLOAT) RETURNS FLOAT
|
|
REQUIRE X1 - X0 != 0.0
|
|
RETURN Y0 + (Y1 - Y0) * (X - X0) / (X1 - X0)
|
|
ENDFUNCTION
|