Free cookie consent management tool by TermsFeed Policy Generator

source: branches/HeuristicLab.Problems.GrammaticalOptimization/DynamicDataDisplay/Charts/Axes/Numeric/NumericConversion.cs @ 12503

Last change on this file since 12503 was 12503, checked in by aballeit, 9 years ago

#2283 added GUI and charts; fixed MCTS

File size: 869 bytes
Line 
1using System;
2using System.Collections.Generic;
3using System.Linq;
4using System.Text;
5
6namespace Microsoft.Research.DynamicDataDisplay.Charts.Axes.Numeric
7{
8  internal sealed class NumericConversion
9  {
10    private readonly double min;
11    private readonly double length;
12    private readonly double minValue;
13    private readonly double valueLength;
14
15    public NumericConversion(double min, double minValue, double max, double maxValue)
16    {
17      this.min = min;
18      this.length = max - min;
19
20      this.minValue = minValue;
21      this.valueLength = maxValue - minValue;
22    }
23
24    public double FromDouble(double value)
25    {
26      double ratio = (value - min) / length;
27
28      return minValue + ratio * valueLength;
29    }
30
31    public double ToDouble(double value)
32    {
33      double ratio = (value - minValue) / valueLength;
34
35      return min + length * ratio;
36    }
37  }
38}
Note: See TracBrowser for help on using the repository browser.