Newer
Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
using System;
using System.Collections.Generic;
namespace WindStressPRM
{
/// <summary>
/// Generic Matrix of type T
/// </summary>
/// <typeparam name="T"></typeparam>
public class Matrix<T>
{
/// <summary>
/// Size of cell. In meters
/// </summary>
public CellSize Size { get; set; }
/// <summary>
/// Cells Container
/// </summary>
public T[,] Cells { get; set; }
/// <summary>
/// Number of rows in matrix
/// </summary>
/// <returns></returns>
public int RowsCount()
{
return Cells.Rank > 0 ? Cells.GetLength(0) : 0;
}
/// <summary>
/// Number of columns
/// </summary>
/// <returns></returns>
public int ColumnCount()
{
return Cells.Rank > 1 ? Cells.GetLength(1) : 0;
}
}
/// <summary>
/// Cell Sizes
/// Параметры ячейки (регулярной сетки)
/// </summary>
public class CellSize
{
/// <summary>
/// ширина ячейки (расстояние между соседними по широте центрами ячеек)
/// </summary>
public double Width { get; set; }
/// <summary>
/// высота ячейки (расстояние между соседними по долготе центрами ячеек)
/// </summary>
public double Height { get; set; }
/// <summary>
/// designated constructor
/// </summary>
/// <param name="wdh">Cell Width</param>
/// <param name="hgh">Cell Height</param>
public CellSize(double wdh, double hgh)
{
this.Width = wdh;
this.Height = hgh;
if (!(this.CheckValue()))
{
throw new System.ArgumentException("Cell width or height values are incorrect!");
}
}
/// <summary>
/// Проверка валидности полей
/// </summary>
/// <returns></returns>
public bool CheckValue()
{
return Width > 0 && Height > 0;
}
}
}