mirror of
https://github.com/ICDSystems/ICD.Common.Utils.git
synced 2026-02-11 02:35:05 +00:00
Merge branch 'MapRangeValidation' of Common/Utils into dev
This commit is contained in:
@@ -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);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user