wasSharp
/Numerics.cs |
@@ -4,12 +4,9 @@ |
// rights of fair usage, the disclaimer and warranty conditions. // |
/////////////////////////////////////////////////////////////////////////// |
|
using System; |
using System.Linq.Expressions; |
|
namespace wasSharp |
{ |
public class Numerics |
public static class Numerics |
{ |
/////////////////////////////////////////////////////////////////////////// |
// Copyright (C) Wizardry and Steamworks 2015 - License: GNU GPLv3 // |
@@ -26,20 +23,9 @@ |
/// yMax - the upper bound of the target range |
/// </remarks> |
/// <returns>a value in x mapped in the range of y</returns> |
public static Func<double, double, double, double, double, double> MapValueToRange = |
((Expression<Func<double, double, double, double, double, double>>) |
((value, xMin, xMax, yMin, yMax) => yMin + ( |
( |
yMax - yMin |
) |
* |
( |
value - xMin |
) |
/ |
( |
xMax - xMin |
) |
))).Compile(); |
public static double MapValueToRange(double value, double xMin, double xMax, double yMin, double yMax) |
{ |
return yMin + (yMax - yMin)*(value - xMin)/(xMax - xMin); |
} |
} |
} |