Normalise
clamp clamps values to the -1…1 scale:
Numbers.Bipolar.clamp(-0.5); // -0.5Numbers.Bipolar.clamp(1.1); // 1fromScalar will convert from 0..1 to -1..1, throwing an error if input is out of the 0..1 range.
// Scalar 0 = -100%Numbers.Bipolar.fromScalar(0); // -1;// Scalar 0.5 = 0%Numbers.Bipolar.fromScalar(0.5); // 0;// Scalar 1 = 100%Numbers.Bipolar.fromScalar(1); // 1;While fromScalar works with input values in 0..1 range, scale allows for an arbitrary input range
// 50 is in the the middle of 0..10, thus 0%Numbers.Bipolar.scale(50, 0, 100); // 0scaleUnclamped allows return values that exceed the range to also exceed the Bipolar range:
// Scale the input value 10 with a scale of 0,4Numbers.Bipolar.scaleUnclamped(10, 0, 4); // 4// Whereas:Numbers.Bipolar.scale(10, 0, 4); // 1