I have a value from 0 to 200 where 0 is better quality and 200 the worst quality.
How could I convert (In obj-c/cocoa framework) that to an integer from 0-5 being 5 best?.
For example 200 would be 0 and 0 would be 5.
In general case if you have to transform Q = [A, B]
to Q' = [A', B']
, where f(A) = B'
and f(B) = A'
, then an arbitrary X
in space [A, B]
will have for [A', B']
the following value:
X' = X * k + d;
where
k = (B' - A') / (A - B);
d = A' - B * k;
So, for your case we have A = 200
, B = 0
and A' = 5
, B' = 1
, resulting:
k = -1/50
d = 5
an arbitrary value x
from [0, 200]
space will be translated as follow:
x' = x * (-1 / 50) + 5;
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With