34using System.Runtime.InteropServices;
36using System.Xml.Serialization;
51 [StructLayout(LayoutKind.Sequential, Size = Matrix2x2.Size)]
52 [AdvBrowsableOrder(
"Rx,Ry")]
53#if !CompactFramework && !WindowsCE && !PocketPC && !XBOX360 && !SILVERLIGHT && !WINDOWS_PHONE && !NETFX_CORE
89 #region static methods
92 Copy(ref matrix, destArray, 0);
98 destArray[index] = matrix.m00;
99 destArray[++index] = matrix.m01;
101 destArray[++index] = matrix.m10;
102 destArray[++index] = matrix.m11;
106 Copy(sourceArray, 0, out result);
112 result.m00 = sourceArray[index];
113 result.m01 = sourceArray[++index];
115 result.m10 = sourceArray[++index];
116 result.m11 = sourceArray[++index];
126 destArray[index] = matrix.m00;
127 destArray[++index] = matrix.m10;
129 destArray[++index] = matrix.m01;
130 destArray[++index] = matrix.m11;
140 result.m00 = sourceArray[index];
141 result.m10 = sourceArray[++index];
143 result.m01 = sourceArray[++index];
144 result.m11 = sourceArray[++index];
149 dest.m00 = source.m00;
150 dest.m01 = source.m01;
152 dest.m10 = source.m10;
153 dest.m11 = source.m11;
157 dest.m00 = source.m00;
158 dest.m01 = source.m01;
160 dest.m10 = source.m10;
161 dest.m11 = source.m11;
165 dest.m00 = source.m00;
166 dest.m01 = source.m01;
168 dest.m10 = source.m10;
169 dest.m11 = source.m11;
175 Lerp(ref left, ref right, ref amount, out result);
180 result.m00 = (right.m00 - left.m00) * amount + left.m00;
181 result.m01 = (right.m01 - left.m01) * amount + left.m01;
183 result.m10 = (right.m10 - left.m10) * amount + left.m10;
184 result.m11 = (right.m11 - left.m11) * amount + left.m11;
207 Scalar m00 = left.m00 * right.m00 + left.m01 * right.m10;
208 Scalar m01 = left.m00 * right.m01 + left.m01 * right.m11;
210 Scalar m10 = left.m10 * right.m00 + left.m11 * right.m10;
211 Scalar m11 = left.m10 * right.m01 + left.m11 * right.m11;
231 result.
m00 = left.
m00 * scalar;
232 result.
m01 = left.
m01 * scalar;
234 result.
m10 = left.
m10 * scalar;
235 result.
m11 = left.
m11 * scalar;
241 result.m00 = left.m00 * scalar;
242 result.m01 = left.m01 * scalar;
244 result.m10 = left.m10 * scalar;
245 result.m11 = left.m11 * scalar;
268 result.m00 = left.m00 + right.m00;
269 result.m01 = left.m01 + right.m01;
271 result.m10 = left.m10 + right.m10;
272 result.m11 = left.m11 + right.m11;
294 result.m00 = left.m00 - right.m00;
295 result.m01 = left.m01 - right.m01;
297 result.m10 = left.m10 - right.m10;
298 result.m11 = left.m11 - right.m11;
320 Negate(ref source, out source);
324 result.m00 = -source.m00;
325 result.m01 = -source.m01;
327 result.m10 = -source.m10;
328 result.m11 = -source.m11;
334 Invert(ref source, out result);
340 Scalar detInv = 1 / (source.m00 *
m11 - source.m01 * source.m10);
341 result.m01 = detInv * -source.m01;
342 result.m11 = detInv * source.m00;
343 result.m00 = detInv *
m11;
344 result.m10 = detInv * -source.m10;
355 result = (source.m00 * source.m11 - source.m01 * source.m10);
367 result.m00 = source.m00;
368 result.m01 = source.m10;
370 result.m11 = source.m11;
382 result.m01 = -source.m01;
383 result.m11 = source.m00;
385 result.m10 = -source.m10;
397 result.m01 = source.m01;
398 result.m11 = -source.m00;
400 result.m10 = source.m10;
408 Copy(array, 0, out result);
431 result.m01 = -result.m10;
432 result.m11 = result.m00;
438 result.
m00 = scale.
X;
439 result.
m11 = scale.
Y;
446 result.m00 = scale.X;
447 result.m11 = scale.Y;
459#if !CompactFramework && !WindowsCE && !PocketPC && !XBOX360 && !SILVERLIGHT
477 left.m00 == right.m00 && left.m01 == right.m01 &&
478 left.m10 == right.m10 && left.m11 == right.m11;
490 Scalar detInv = 1 / (source.m00 * source.m11 - source.m01 * source.m10);
491 result.m10 = detInv * -source.m01;
492 result.m11 = detInv * source.m00;
493 result.m00 = detInv * source.m11;
494 result.m01 = detInv * -source.m10;
504 Scalar detInv = 1 / (source.m00 * source.m11 - source.m01 * source.m10);
505 result.m10 = detInv * -source.m01;
506 result.m11 = detInv * source.m00;
507 result.m00 = detInv * source.m11;
508 result.m01 = detInv * -source.m10;
529 this.m00 =
m00; this.m01 =
m01;
530 this.m10 =
m10; this.m11 =
m11;
538 [InstanceConstructor(
"Rx,Ry")]
549 Copy(values, index, out
this);
584 [
System.ComponentModel.Description(
"The First row of the Matrix2x2")]
606 [
System.ComponentModel.Description(
"The Second row of the Matrix2x2")]
668 Invert(ref
this, out result);
676 #endregion Properties
746 Copy(ref
this, array, index);
754 Copy(array, index, out
this);
779 m00.GetHashCode() ^
m01.GetHashCode() ^
780 m10.GetHashCode() ^
m11.GetHashCode();
791 return Equals(ref
this, ref other);
803 public Scalar this[
int rowIndex,
int columnIndex]
819 ThrowHelper.CheckIndex(
"rowIndex", rowIndex,
RowCount);
820 ThrowHelper.CheckIndex(
"columnIndex", columnIndex,
ColumnCount);
825 pM[(
ColumnCount * rowIndex) + columnIndex] = value;
837 public Scalar this[
int index]
841 ThrowHelper.CheckIndex(
"index", index,
Count);
844 fixed (
Scalar* pMatrix = &this.m00)
846 return pMatrix[index];
853 ThrowHelper.CheckIndex(
"index", index,
Count);
856 fixed (
Scalar* pMatrix = &this.m00)
858 pMatrix[index] = value;
865 #region Operator overloads
931 result.
m00 = matrix.
m00 * scalar;
932 result.
m01 = matrix.
m01 * scalar;
934 result.
m10 = matrix.
m10 * scalar;
935 result.
m11 = matrix.
m11 * scalar;
949 result.
m00 = matrix.
m00 * scalar;
950 result.
m01 = matrix.
m01 * scalar;
952 result.
m10 = matrix.
m10 * scalar;
953 result.
m11 = matrix.
m11 * scalar;
989 return !(left == right);
static Scalar Cos(Scalar d)
static Scalar Sin(Scalar a)
static string CreateMatrixFormatableString(int RowCount, int ColumnCount)
static string CreateMatrixFormatString(int RowCount, int ColumnCount)
static Exception GetThrowIndex(string name, int count)
static void CheckCopy(Scalar[] array, int index, int count)
int Count
Gets a 32-bit integer that represents the total number of elements in all the dimensions of IAdvanceV...
int RowCount
Gets a 32-bit integer that represents the total number of Rows in the IMatrix.
int ColumnCount
Gets a 32-bit integer that represents the total number of Columns in the IMatrix.
A 2x2 matrix which can represent rotations for 2D vectors.
static void CopyTranspose(Scalar[] sourceArray, out Matrix2x2 result)
static void FromScale(ref Vector2D scale, out Matrix2x2 result)
static void Multiply(ref Matrix2x2 left, ref Scalar scalar, out Matrix2x2 result)
static Matrix2x2 Subtract(Matrix2x2 left, Matrix2x2 right)
Used to subtract two matrices.
static Matrix2x2 FromArray(Scalar[] array)
static Matrix2x2 operator-(Matrix2x2 left, Matrix2x2 right)
Used to subtract two matrices.
Vector2D GetRow(int rowIndex)
static void Add(ref Matrix2x2 left, ref Matrix2x2 right, out Matrix2x2 result)
static Matrix2x2 GetAdjoint(Matrix2x2 source)
static Matrix2x2 CreateNormal(Matrix2x3 source)
static Matrix2x2 FromScale(Vector2D scale)
Vector2D Rx
The X Row or row zero.
Scalar[] ToArray()
Copies the elements of the IAdvanceValueType to a new array of Scalar .
int IAdvanceValueType. Count
static readonly string FormatableString
static readonly string FormatString
static void Copy(ref Matrix3x3 source, out Matrix2x2 dest)
override string ToString()
Vector2D GetColumn(int columnIndex)
static void Lerp(ref Matrix2x2 left, ref Matrix2x2 right, ref Scalar amount, out Matrix2x2 result)
static Matrix2x2 Multiply(Matrix2x2 left, Scalar scalar)
Used to multiply a Matrix2x2 object by a scalar value..
static void Copy(ref Matrix4x4 source, out Matrix2x2 dest)
static void Copy(ref Matrix2x3 source, out Matrix2x2 dest)
static Scalar GetDeterminant(Matrix2x2 source)
static void Copy(Scalar[] sourceArray, out Matrix2x2 result)
static void CreateNormal(ref Matrix3x3 source, out Matrix2x2 result)
static void CopyTranspose(ref Matrix2x2 matrix, Scalar[] destArray, int index)
Matrix2x2(Scalar m00, Scalar m01, Scalar m10, Scalar m11)
Creates a new Matrix3 with all the specified parameters.
string ToStringInternal(string FormatString)
static Matrix2x2 operator+(Matrix2x2 left, Matrix2x2 right)
Used to add two matrices together.
static bool Equals(ref Matrix2x2 left, ref Matrix2x2 right)
static void Transpose(ref Matrix2x2 source, out Matrix2x2 result)
void CopyTransposedTo(Scalar[] array, int index)
string ToString(string format)
turns the object into a string representation of itself with a special format for each Scaler in it.
static void Copy(ref Matrix2x2 matrix, Scalar[] destArray)
static void Negate(ref Matrix2x2 source, out Matrix2x2 result)
static void Invert(ref Matrix2x2 source, out Matrix2x2 result)
const int Count
The number of Scalar values in the class.
Matrix2x2 Transposed
Swap the rows of the matrix with the columns.
static Matrix2x2 Add(Matrix2x2 left, Matrix2x2 right)
Used to add two matrices together.
Vector2D Ry
The Y Row or row one.
static void Subtract(ref Matrix2x2 left, ref Matrix2x2 right, out Matrix2x2 result)
static bool TryParse(string s, out Matrix2x2 result)
static Matrix2x2 Lerp(Matrix2x2 left, Matrix2x2 right, Scalar amount)
static readonly Matrix2x2 Identity
Scalar[,] ToMatrixArray()
Matrix2x2(Scalar[] values)
static bool operator==(Matrix2x2 left, Matrix2x2 right)
Test two matrices for (value) equality
static void FromRotation(ref Scalar radianAngle, out Matrix2x2 result)
static Matrix2x2 Invert(Matrix2x2 source)
static Matrix2x2 FromRotation(Scalar radianAngle)
override int GetHashCode()
static bool Equals(Matrix2x2 left, Matrix2x2 right)
static void GetCofactor(ref Matrix2x2 source, out Matrix2x2 result)
static Matrix2x2 GetCofactor(Matrix2x2 source)
static void GetAdjoint(ref Matrix2x2 source, out Matrix2x2 result)
static void Copy(Scalar[] sourceArray, int index, out Matrix2x2 result)
void CopyTo(Scalar[] array, int index)
Copies all the elements of the IAdvanceValueType to the specified one-dimensional Array of Scalar.
static Matrix2x2 Multiply(Matrix2x2 left, Matrix2x2 right)
Used to multiply (concatenate) two Matrix4x4s.
Matrix2x2(Scalar[] values, int index)
static void Multiply(ref Matrix2x2 left, ref Matrix2x2 right, out Matrix2x2 result)
const int RowCount
The number of rows.
static Matrix2x2 Parse(string s)
static void Negate(ref Matrix2x2 source)
static void CopyTranspose(ref Matrix2x2 matrix, Scalar[] destArray)
static Matrix2x2 CreateNormal(Matrix3x3 source)
static Matrix2x2 Negate(Matrix2x2 source)
Negates a Matrix2x2.
static void GetDeterminant(ref Matrix2x2 source, out Scalar result)
void CopyTransposedFrom(Scalar[] array, int index)
static Matrix2x2 FromTransposedArray(Scalar[] array)
static bool operator!=(Matrix2x2 left, Matrix2x2 right)
const int ColumnCount
The number of columns.
const int Size
The Size of the class in bytes;
static void CreateNormal(ref Matrix2x3 source, out Matrix2x2 result)
static readonly Matrix2x2 Zero
static void Copy(ref Matrix2x2 matrix, Scalar[] destArray, int index)
bool Equals(Matrix2x2 other)
override bool Equals(object obj)
Scalar[] ToTransposedArray()
void SetColumn(int columnIndex, Vector2D value)
static Matrix2x2 operator*(Matrix2x2 left, Matrix2x2 right)
Multiply (concatenate) two Matrix3 instances together.
static Matrix2x2 Transpose(Matrix2x2 source)
void SetRow(int rowIndex, Vector2D value)
static void CopyTranspose(Scalar[] sourceArray, int index, out Matrix2x2 result)
void CopyFrom(Scalar[] array, int index)
Copies all the elements of the IAdvanceValueType, of the specified one-dimensional Array to the IAdva...
Matrix2x2(Vector2D xAxis, Vector2D yAxis)
Create a new Matrix from 3 Vertex3 objects.
A 2x3 matrix which can represent rotations around axes.
A 3x3 matrix which can represent rotations around axes.
This is the Vector Class.
Scalar X
This is the X value. (Usually represents a horizontal position or direction.)
Scalar Y
This is the Y value. (Usually represents a vertical position or direction.)