Merge branch 'MapRangeValidation' of Common/Utils into dev

This commit is contained in:
Drew Tingen
2018-04-05 13:48:46 +00:00
committed by Gogs

View File

@@ -71,6 +71,9 @@ namespace ICD.Common.Utils
/// <returns>The newly mapped value</returns>
public static double MapRange(double inputStart, double inputEnd, double outputStart, double outputEnd, double value)
{
if (inputStart.Equals(inputEnd))
throw new DivideByZeroException();
double slope = (outputEnd - outputStart) / (inputEnd - inputStart);
return outputStart + slope * (value - inputStart);
}