wasSharp – Blame information for rev 6

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