norm static method
Normalizes a value within a given range.
Given a value
, min
and max
, returns a normalized value between 0
and 1, representing the position of the value
within the min
-max
range.
Example:
final value = 50;
final min = 0;
final max = 100;
final normalizedValue = Math.norm(value, min, max);
print(normalizedValue); // 0.5
Implementation
@pragma("vm:prefer-inline")
static double norm(num value, num min, num max) {
return (value - min) / (max - min);
}