Free cookie consent management tool by TermsFeed Policy Generator

source: branches/HeuristicLab.Problems.GrammaticalOptimization/DynamicDataDisplay/Transforms/Log10Transform.cs @ 13376

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

#2283 added GUI and charts; fixed MCTS

File size: 1.5 KB
Line 
1using System;
2using System.Collections.Generic;
3using System.Linq;
4using System.Text;
5using System.Windows;
6
7namespace Microsoft.Research.DynamicDataDisplay
8{
9  /// <summary>
10  /// Represents a logarithmic transform of both x- and y-values.
11  /// </summary>
12  public sealed class Log10Transform : DataTransform
13  {
14    /// <summary>
15    /// Initializes a new instance of the <see cref="Log10Transform"/> class.
16    /// </summary>
17    public Log10Transform() { }
18
19    /// <summary>
20    /// Transforms the point in data coordinates to viewport coordinates.
21    /// </summary>
22    /// <param name="pt">The point in data coordinates.</param>
23    /// <returns>
24    /// Transformed point in viewport coordinates.
25    /// </returns>
26    public override Point DataToViewport(Point pt)
27    {
28      double x = pt.X;
29      double y = pt.Y;
30
31      x = x < 0 ? Double.MinValue : Math.Log10(x);
32      y = y < 0 ? Double.MinValue : Math.Log10(y);
33
34      return new Point(x, y);
35    }
36
37    /// <summary>
38    /// Transforms the point in viewport coordinates to data coordinates.
39    /// </summary>
40    /// <param name="pt">The point in viewport coordinates.</param>
41    /// <returns>Transformed point in data coordinates.</returns>
42    public override Point ViewportToData(Point pt)
43    {
44      return new Point(Math.Pow(10, pt.X), Math.Pow(10, pt.Y));
45    }
46
47    /// <summary>
48    /// Gets the data domain of this dataTransform.
49    /// </summary>
50    /// <value>The data domain of this dataTransform.</value>
51    public override DataRect DataDomain
52    {
53      get { return DataDomains.XYPositive; }
54    }
55  }
56}
Note: See TracBrowser for help on using the repository browser.