diff --git a/ICD.Common.Utils/MathUtils.cs b/ICD.Common.Utils/MathUtils.cs
index 1f44412..e4427ac 100644
--- a/ICD.Common.Utils/MathUtils.cs
+++ b/ICD.Common.Utils/MathUtils.cs
@@ -78,6 +78,24 @@ namespace ICD.Common.Utils
return outputStart + slope * (value - inputStart);
}
+ ///
+ /// Returns the value after the input range has been mapped to a new range
+ ///
+ /// Input start.
+ /// Input end.
+ /// Output start.
+ /// Output end.
+ /// Value.
+ /// The newly mapped value
+ public static decimal MapRange(decimal inputStart, decimal inputEnd, decimal outputStart, decimal outputEnd, decimal value)
+ {
+ if (inputStart.Equals(inputEnd))
+ throw new DivideByZeroException();
+
+ decimal slope = (outputEnd - outputStart) / (inputEnd - inputStart);
+ return outputStart + slope * (value - inputStart);
+ }
+
///
/// Returns the value after the input range has been mapped to a new range
///
@@ -120,6 +138,42 @@ namespace ICD.Common.Utils
return (ushort)MapRange((double)inputStart, inputEnd, outputStart, outputEnd, value);
}
+ ///
+ /// Returns the value after the input range has been mapped to a new range
+ ///
+ /// Input start.
+ /// Input end.
+ /// Output start.
+ /// Output end.
+ /// Value.
+ /// The newly mapped value
+ public static ulong MapRange(ulong inputStart, ulong inputEnd, ulong outputStart, ulong outputEnd, ulong value)
+ {
+ if (inputStart.Equals(inputEnd))
+ throw new DivideByZeroException();
+
+ ulong slope = (outputEnd - outputStart) / (inputEnd - inputStart);
+ return outputStart + slope * (value - inputStart);
+ }
+
+ ///
+ /// Returns the value after the input range has been mapped to a new range
+ ///
+ /// Input start.
+ /// Input end.
+ /// Output start.
+ /// Output end.
+ /// Value.
+ /// The newly mapped value
+ public static long MapRange(long inputStart, long inputEnd, long outputStart, long outputEnd, long value)
+ {
+ if (inputStart.Equals(inputEnd))
+ throw new DivideByZeroException();
+
+ long slope = (outputEnd - outputStart) / (inputEnd - inputStart);
+ return outputStart + slope * (value - inputStart);
+ }
+
///
/// Maps the date in the given range to the float range 0.0f to 1.0f.
/// 0.5f - The date is half way between the end points.