It would be interesting to note that in some cases general formulae mentioned in this VMK, namely (in short form)
might be more efficient even when it is used for two particular cases (when output is in the range [0, 1] and [1, 0]) than the formula for those cases, i.e.:
Y = (X - Ax) / (Bx - Ax) (**)
The point is that modern hardware can have a dedicated instruction MADD, stands for Multiply then ADD. It has three arguments: MADD(a, b, c) and equivalent to a * b + c.
The multiplication-add (MADD) is merely a multiplication followed by a summation. Some processors, such as AltiVec, do not support a stand-alone multiplication, some support only the multiplication-add, and some support both. But it is much more efficient to call a MADD-type instruction when appropriate, instead of separately.
So, to use MADD for (*) one can write
But to extract MADDs' arguments from the formula (**), although that formula seems more compact then full version of (*), one has to convert it back to (**) anyway, i.e.:
Y = (X - Ax) / (Bx - Ax) =>
M = 1 / ( Bx - Ax )
B = - Ax * M
// maybe in cycle
Y = MADD(X, M, B).
Quite importantly, MADD is available on most modern GPU and accessible via shader's assembly languages (for shader programming mostly). For instance, OpenGL HLSL syntax for MADD is:
mad dst, src0, src1, src2
OK, this is just a side thought. I like this VMK.