Inverse of non-continuous scale

18 Views Asked by At

I'm currently struggling with inverting a value on the non-continuous scale

-2 0 1 5

to a value on the following (inverted) scale

5 1 0 -2

What I tried before is the commonly suggested approach of

value = maxOfScale + minOfScale - value

but this seems only to evaluate correctly when using non-negative values.

Is there a fairly straight forward approach for this?