/Main/src/DynamicDataDisplay/DataSources/MultiDimensional/DataSource2DHelper.cs
C# | 51 lines | 43 code | 8 blank | 0 comment | 4 complexity | 6bfa30c145de2028dbc48e01c5ae6e8a MD5 | raw file
Possible License(s): CC-BY-SA-3.0
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Windows;
-
- namespace Microsoft.Research.DynamicDataDisplay.DataSources.MultiDimensional
- {
- public static class DataSource2DHelper
- {
- public static Point[,] CreateUniformGrid(int width, int height, double gridWidth, double gridHeight)
- {
- return CreateUniformGrid(width, height, 0, 0, gridWidth / width, gridHeight / height);
- }
-
- public static Point[,] CreateUniformGrid(int width, int height, double xStart, double yStart, double xStep, double yStep)
- {
- Point[,] result = new Point[width, height];
-
- double x = xStart;
- for (int ix = 0; ix < width; ix++)
- {
- double y = yStart;
- for (int iy = 0; iy < height; iy++)
- {
- result[ix, iy] = new Point(x, y);
-
- y += yStep;
- }
- x += xStep;
- }
-
- return result;
- }
-
- public static Vector[,] CreateVectorData(int width, int height, Func<int, int, Vector> generator)
- {
- Vector[,] result = new Vector[width, height];
-
- for (int ix = 0; ix < width; ix++)
- {
- for (int iy = 0; iy < height; iy++)
- {
- result[ix, iy] = generator(ix, iy);
- }
- }
-
- return result;
- }
- }
- }