| | 1 | | namespace Morpho25.Geometry |
| | 2 | | { |
| | 3 | | /// <summary> |
| | 4 | | /// Matrix 3D class. |
| | 5 | | /// </summary> |
| | 6 | | /// <typeparam name="T">Type to use.</typeparam> |
| | 7 | | public class Matrix3d<T> |
| | 8 | | { |
| | 9 | | private readonly T[,,] _values; |
| | 10 | |
|
| | 11 | | /// <summary> |
| | 12 | | /// Get a value. |
| | 13 | | /// </summary> |
| | 14 | | /// <param name="x">X index.</param> |
| | 15 | | /// <param name="y">Y index.</param> |
| | 16 | | /// <param name="z">Z index.</param> |
| | 17 | | /// <returns>Value.</returns> |
| | 18 | | public T this[int x, int y, int z] |
| | 19 | | { |
| 0 | 20 | | get { return _values[x, y, z]; } |
| 0 | 21 | | set { _values[x, y, z] = value; } |
| | 22 | | } |
| | 23 | |
|
| | 24 | | /// <summary> |
| | 25 | | /// Create a new Matrix 3D. |
| | 26 | | /// </summary> |
| | 27 | | /// <param name="x">Size in X.</param> |
| | 28 | | /// <param name="y">Size in Y.</param> |
| | 29 | | /// <param name="z">Size in Z.</param> |
| 0 | 30 | | public Matrix3d(int x, int y, int z) |
| 0 | 31 | | { |
| 0 | 32 | | _values = new T[x, y, z]; |
| 0 | 33 | | } |
| | 34 | |
|
| | 35 | | /// <summary> |
| | 36 | | /// Create a new Matrix 3D. |
| | 37 | | /// </summary> |
| | 38 | | /// <param name="x">Size in X.</param> |
| | 39 | | /// <param name="y">Size in Y.</param> |
| | 40 | | /// <param name="z">Size in Z.</param> |
| | 41 | | /// <param name="value">Default value to use.</param> |
| 0 | 42 | | public Matrix3d(int x, int y, int z, T value) |
| 0 | 43 | | { |
| 0 | 44 | | _values = new T[x, y, z]; |
| 0 | 45 | | for (int i = 0; i < x; i++) |
| 0 | 46 | | for (int j = 0; j < y; j++) |
| 0 | 47 | | for(int k = 0; k < z; k++) |
| 0 | 48 | | { |
| 0 | 49 | | _values[i, j, k] = value; |
| 0 | 50 | | } |
| 0 | 51 | | } |
| | 52 | | /// <summary> |
| | 53 | | /// Get X size. |
| | 54 | | /// </summary> |
| | 55 | | /// <returns>X size.</returns> |
| | 56 | | public int GetLengthX() |
| 0 | 57 | | { |
| 0 | 58 | | return _values.GetLength(0); |
| 0 | 59 | | } |
| | 60 | | /// <summary> |
| | 61 | | /// Get Y size. |
| | 62 | | /// </summary> |
| | 63 | | /// <returns>Y size.</returns> |
| | 64 | | public int GetLengthY() |
| 0 | 65 | | { |
| 0 | 66 | | return _values.GetLength(1); |
| 0 | 67 | | } |
| | 68 | | /// <summary> |
| | 69 | | /// Get Z size. |
| | 70 | | /// </summary> |
| | 71 | | /// <returns>Z size.</returns> |
| | 72 | | public int GetLengthZ() |
| 0 | 73 | | { |
| 0 | 74 | | return _values.GetLength(2); |
| 0 | 75 | | } |
| | 76 | | } |
| | 77 | | } |