Jypeli  9
The simple game programming library
Interfaces.cs
Siirry tämän tiedoston dokumentaatioon.
1 #region MIT License
2 /*
3  * Copyright (c) 2005-2008 Jonathan Mark Porter. http://physics2d.googlepages.com/
4  *
5  * Permission is hereby granted, free of charge, to any person obtaining a copy
6  * of this software and associated documentation files (the "Software"), to deal
7  * in the Software without restriction, including without limitation the rights to
8  * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
9  * the Software, and to permit persons to whom the Software is furnished to do so,
10  * subject to the following conditions:
11  *
12  * The above copyright notice and this permission notice shall be
13  * included in all copies or substantial portions of the Software.
14  *
15  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
16  * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
17  * PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18  * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
19  * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
20  * OTHER DEALINGS IN THE SOFTWARE.
21  */
22 #endregion
23 
24 
25 
26 
27 #if UseDouble
28 using Scalar = System.Double;
29 #else
30 using Scalar = System.Single;
31 #endif
32 using System;
33 
34 namespace AdvanceMath
35 {
36  public interface IAdvanceValueType
37  {
41  int Count { get;}
42 #if UNSAFE
43  Scalar this[int index] { get;set;}
49 #endif
50  Scalar[] ToArray();
60  void CopyTo(Scalar[] array, int index);
66  void CopyFrom(Scalar[] array, int index);
72  string ToString(string format);
73  }
74  public interface IVector<V> : IAdvanceValueType, IEquatable<V>
75  where V : struct, IVector<V>
76  {
81  Scalar Magnitude { get;set;}
91  V Normalized { get;}
92  }
93  public interface IMatrix : IAdvanceValueType
94  {
98  int RowCount { get;}
102  int ColumnCount { get;}
103 #if UNSAFE
104  Scalar this[int row, int column] { get;set;}
111 #endif
112  Scalar[,] ToMatrixArray();
131  void CopyTransposedTo(Scalar[] array, int index);
137  void CopyTransposedFrom(Scalar[] array, int index);
143  }
144 
145  public interface IMatrix<M, VC, VR> : IMatrix, IAdvanceValueType, IEquatable<M>
146  where M : struct, IMatrix<M, VC, VR>
147  where VC : struct, IVector<VC>
148  where VR : struct, IVector<VR>
149  {
155  VC GetColumn(int columnIndex);
161  void SetColumn(int columnIndex, VC value);
167  VR GetRow(int rowIndex);
173  void SetRow(int rowIndex, VR value);
178  M Inverted { get;}
183  M Transposed { get;}
188  M Adjoint { get;}
192  M Cofactor { get;}
193  }
194 
195 
196 
197 }
AdvanceMath.IAdvanceValueType.CopyFrom
void CopyFrom(Scalar[] array, int index)
Copies all the elements of the IAdvanceValueType, of the specified one-dimensional Array to the IAdva...
AdvanceMath.IAdvanceValueType.ToString
string ToString(string format)
turns the object into a string representation of itself with a special format for each Scaler in it.
AdvanceMath.IMatrix.SetRow
void SetRow(int rowIndex, VR value)
Sets the VR at the specified Row.
AdvanceMath.IMatrix.Inverted
M Inverted
Gets the Inverse of the IMatrix
Definition: Interfaces.cs:178
AdvanceMath.IAdvanceValueType.Count
int Count
Gets a 32-bit integer that represents the total number of elements in all the dimensions of IAdvanceV...
Definition: Interfaces.cs:41
AdvanceMath.IMatrix
Definition: Interfaces.cs:94
AdvanceMath.IVector.Normalized
V Normalized
Gets the Normalized Vector. (Unit Vector)
Definition: Interfaces.cs:91
AdvanceMath.IMatrix.SetColumn
void SetColumn(int columnIndex, VC value)
Sets the VC at the specified Column.
AdvanceMath.IMatrix.ColumnCount
int ColumnCount
Gets a 32-bit integer that represents the total number of Columns in the IMatrix.
Definition: Interfaces.cs:102
AdvanceMath.IMatrix.Determinant
Scalar Determinant
Gets the Determinant of the IMatrix
Definition: Interfaces.cs:142
AdvanceMath.IAdvanceValueType.CopyTo
void CopyTo(Scalar[] array, int index)
Copies all the elements of the IAdvanceValueType to the specified one-dimensional Array of Scalar.
AdvanceMath.IAdvanceValueType.ToArray
Scalar[] ToArray()
Copies the elements of the IAdvanceValueType to a new array of Scalar .
AdvanceMath.IMatrix.CopyTransposedTo
void CopyTransposedTo(Scalar[] array, int index)
Copies all the elements, in a Transposed order, of the IAdvanceValueType to the specified one-dimensi...
AdvanceMath.IMatrix.Adjoint
M Adjoint
Gets the Adjoint (Conjugate Transpose) of the IMatrix
Definition: Interfaces.cs:188
Scalar
System.Single Scalar
Definition: Clamped.cs:29
AdvanceMath.IVector.Magnitude
Scalar Magnitude
Gets or Sets the Magnitude (Length of a Vector).
Definition: Interfaces.cs:81
AdvanceMath.IAdvanceValueType
Definition: Interfaces.cs:37
AdvanceMath.IMatrix.Cofactor
M Cofactor
Gets the Cofactor (The Transpose of the Adjoint) of the IMatrix
Definition: Interfaces.cs:192
AdvanceMath.IMatrix.ToTransposedArray
Scalar[] ToTransposedArray()
Copies the elements, in a Transposed order, of the IMatrix to a new array of Scalar.
AdvanceMath.IMatrix.RowCount
int RowCount
Gets a 32-bit integer that represents the total number of Rows in the IMatrix.
Definition: Interfaces.cs:98
System
Definition: CFFauxAttributes.cs:29
AdvanceMath.IVector
Definition: Interfaces.cs:76
AdvanceMath.IMatrix.CopyTransposedFrom
void CopyTransposedFrom(Scalar[] array, int index)
Copies all the elements, in a Transposed order, up to the IAdvanceValueType.Count of the IAdvanceValu...
AdvanceMath.IMatrix.GetColumn
VC GetColumn(int columnIndex)
Gets the VC at the specified Column.
AdvanceMath.IMatrix.GetRow
VR GetRow(int rowIndex)
Gets the VR at the specified Row.
AdvanceMath
Definition: Clamped.cs:36
AdvanceMath.IVector.MagnitudeSq
Scalar MagnitudeSq
Gets the Squared Magnitude (IE Magnitude*Magnitude).
Definition: Interfaces.cs:86
AdvanceMath.IMatrix.Transposed
M Transposed
Gets the Transpose of the IMatrix
Definition: Interfaces.cs:183