Free cookie consent management tool by TermsFeed Policy Generator

source: branches/HeuristicLab.Problems.GrammaticalOptimization/DynamicDataDisplay/DataSources/MultiDimensional/DataSource2DHelper.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: 1.2 KB
Line 
1using System;
2using System.Collections.Generic;
3using System.Linq;
4using System.Text;
5using System.Windows;
6
7namespace Microsoft.Research.DynamicDataDisplay.DataSources.MultiDimensional
8{
9  public static class DataSource2DHelper
10  {
11    public static Point[,] CreateUniformGrid(int width, int height, double gridWidth, double gridHeight)
12    {
13      return CreateUniformGrid(width, height, 0, 0, gridWidth / width, gridHeight / height);
14    }
15
16    public static Point[,] CreateUniformGrid(int width, int height, double xStart, double yStart, double xStep, double yStep)
17    {
18      Point[,] result = new Point[width, height];
19
20      double x = xStart;
21      for (int ix = 0; ix < width; ix++)
22      {
23        double y = yStart;
24        for (int iy = 0; iy < height; iy++)
25        {
26          result[ix, iy] = new Point(x, y);
27
28          y += yStep;
29        }
30        x += xStep;
31      }
32
33      return result;
34    }
35
36    public static Vector[,] CreateVectorData(int width, int height, Func<int, int, Vector> generator)
37    {
38      Vector[,] result = new Vector[width, height];
39
40      for (int ix = 0; ix < width; ix++)
41      {
42        for (int iy = 0; iy < height; iy++)
43        {
44          result[ix, iy] = generator(ix, iy);
45        }
46      }
47
48      return result;
49    }
50  }
51}
Note: See TracBrowser for help on using the repository browser.