Rev | Line | |
---|
[12503] | 1 | using System;
|
---|
| 2 | using System.Collections.Generic;
|
---|
| 3 | using System.Linq;
|
---|
| 4 | using System.Text;
|
---|
| 5 |
|
---|
| 6 | namespace 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.