corrade-vassal – Diff between revs 14 and 16

Subversion Repositories:
Rev:
Show entire fileIgnore whitespace
Rev 14 Rev 16
Line 2... Line 2...
2 // Copyright (C) Wizardry and Steamworks 2013 - License: GNU GPLv3 // 2 // Copyright (C) Wizardry and Steamworks 2013 - License: GNU GPLv3 //
3 // Please see: http://www.gnu.org/licenses/gpl.html for legal details, // 3 // Please see: http://www.gnu.org/licenses/gpl.html for legal details, //
4 // rights of fair usage, the disclaimer and warranty conditions. // 4 // rights of fair usage, the disclaimer and warranty conditions. //
5 /////////////////////////////////////////////////////////////////////////// 5 ///////////////////////////////////////////////////////////////////////////
Line 6... Line -...
6   -  
7 using System; -  
8 using System.Linq.Expressions; -  
9   6  
10 namespace wasSharp 7 namespace wasSharp
11 { 8 {
12 public class Numerics 9 public static class Numerics
13 { 10 {
14 /////////////////////////////////////////////////////////////////////////// 11 ///////////////////////////////////////////////////////////////////////////
15 // Copyright (C) Wizardry and Steamworks 2015 - License: GNU GPLv3 // 12 // Copyright (C) Wizardry and Steamworks 2015 - License: GNU GPLv3 //
16 /////////////////////////////////////////////////////////////////////////// 13 ///////////////////////////////////////////////////////////////////////////
Line 24... Line 21...
24 /// xMax - the upper bound of the source range 21 /// xMax - the upper bound of the source range
25 /// yMin - the lower bound of the target range 22 /// yMin - the lower bound of the target range
26 /// yMax - the upper bound of the target range 23 /// yMax - the upper bound of the target range
27 /// </remarks> 24 /// </remarks>
28 /// <returns>a value in x mapped in the range of y</returns> 25 /// <returns>a value in x mapped in the range of y</returns>
29 public static Func<double, double, double, double, double, double> MapValueToRange = 26 public static double MapValueToRange(double value, double xMin, double xMax, double yMin, double yMax)
30 ((Expression<Func<double, double, double, double, double, double>>) -  
31 ((value, xMin, xMax, yMin, yMax) => yMin + ( -  
32 ( -  
33 yMax - yMin -  
34 ) -  
35 * -  
36 ( 27 {
37 value - xMin 28 return yMin + (yMax - yMin)*(value - xMin)/(xMax - xMin);
38 ) -  
39 / -  
40 ( 29 }
41 xMax - xMin -  
42 ) -  
43 ))).Compile(); -  
44 } 30 }
45 } 31 }
46   32