1 | using System;
|
---|
2 | using System.Collections.Generic;
|
---|
3 | using System.Linq;
|
---|
4 | using System.Text;
|
---|
5 | using System.Windows;
|
---|
6 |
|
---|
7 | namespace 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 | }
|
---|