corrade-vassal – Diff between revs 13 and 14

Subversion Repositories:
Rev:
Show entire fileIgnore whitespace
Rev 13 Rev 14
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 -... Line 6...
-   6  
-   7 using System;
-   8 using System.Linq.Expressions;
6   9  
7 namespace wasSharp 10 namespace wasSharp
8 { 11 {
9 public class Numerics 12 public class Numerics
10 { 13 {
Line 13... Line 16...
13 /////////////////////////////////////////////////////////////////////////// 16 ///////////////////////////////////////////////////////////////////////////
14 /// <summary> 17 /// <summary>
15 /// Given a value in a source value range and a target range, map 18 /// Given a value in a source value range and a target range, map
16 /// the value from the source range into the target range. 19 /// the value from the source range into the target range.
17 /// </summary> 20 /// </summary>
-   21 /// <remarks>
18 /// <param name="value">the value to map</param> 22 /// value - the value to map
19 /// <param name="xMin">the lower bound of the source range</param> 23 /// xMin - the lower bound of the source range
20 /// <param name="xMax">the upper bound of the source range</param> 24 /// xMax - the upper bound of the source range
21 /// <param name="yMin">the lower bound of the target range</param> 25 /// yMin - the lower bound of the target range
22 /// <param name="yMax">the upper bound of the target range</param> 26 /// yMax - the upper bound of the target range
-   27 /// </remarks>
-   28 /// <returns>a value in x mapped in the range of y</returns>
23 public static double MapValueToRange(double value, double xMin, double xMax, double yMin, double yMax) 29 public static Func<double, double, double, double, double, double> MapValueToRange =
24 { 30 ((Expression<Func<double, double, double, double, double, double>>)
25 return yMin + ( 31 ((value, xMin, xMax, yMin, yMax) => yMin + (
26 ( 32 (
27 yMax - yMin 33 yMax - yMin
28 ) 34 )
29 * 35 *
30 ( 36 (
31 value - xMin 37 value - xMin
32 ) 38 )
33 / 39 /
34 ( 40 (
35 xMax - xMin 41 xMax - xMin
36 ) 42 )
37 ); 43 ))).Compile();
38 } -  
39 } 44 }
40 } 45 }
41   46