diff --git a/Source/OpenTK/Math/Matrix2.cs b/Source/OpenTK/Math/Matrix2.cs index 5a0000c5..ae628ba9 100644 --- a/Source/OpenTK/Math/Matrix2.cs +++ b/Source/OpenTK/Math/Matrix2.cs @@ -105,7 +105,7 @@ namespace OpenTK } /// - /// Gets the first column of this matrix. + /// Gets or sets the first column of this matrix. /// public Vector2 Column0 { @@ -114,7 +114,7 @@ namespace OpenTK } /// - /// Gets the second column of this matrix. + /// Gets or sets the second column of this matrix. /// public Vector2 Column1 { diff --git a/Source/OpenTK/Math/Matrix2x3.cs b/Source/OpenTK/Math/Matrix2x3.cs index 23bcf5ec..8a5cae5f 100644 --- a/Source/OpenTK/Math/Matrix2x3.cs +++ b/Source/OpenTK/Math/Matrix2x3.cs @@ -88,7 +88,7 @@ namespace OpenTK #region Properties /// - /// Gets the first column of this matrix. + /// Gets or sets the first column of this matrix. /// public Vector2 Column0 { @@ -97,7 +97,7 @@ namespace OpenTK } /// - /// Gets the second column of this matrix. + /// Gets or sets the second column of this matrix. /// public Vector2 Column1 { @@ -106,7 +106,7 @@ namespace OpenTK } /// - /// Gets the third column of this matrix. + /// Gets or sets the third column of this matrix. /// public Vector2 Column2 { @@ -499,10 +499,6 @@ namespace OpenTK #endregion - #region Invert Functions - - #endregion - #region Transpose /// @@ -690,7 +686,9 @@ namespace OpenTK #region IEquatable Members - /// Indicates whether the current matrix is equal to another matrix. + /// + /// Indicates whether the current matrix is equal to another matrix. + /// /// An matrix to compare with this matrix. /// true if the current matrix is equal to the matrix parameter; otherwise, false. public bool Equals(Matrix2x3 other) diff --git a/Source/OpenTK/Math/Matrix2x4.cs b/Source/OpenTK/Math/Matrix2x4.cs index 9597e8e8..63ed8db7 100644 --- a/Source/OpenTK/Math/Matrix2x4.cs +++ b/Source/OpenTK/Math/Matrix2x4.cs @@ -27,6 +27,9 @@ using System.Runtime.InteropServices; namespace OpenTK { + /// + /// Represents a 2x4 matrix. + /// public struct Matrix2x4 : IEquatable { #region Fields @@ -86,37 +89,80 @@ namespace OpenTK #region Properties + /// + /// Gets or sets the first column of the matrix. + /// public Vector2 Column0 { get { return new Vector2(Row0.X, Row1.X); } set { Row0.X = value.X; Row1.X = value.Y; } } + /// + /// Gets or sets the second column of the matrix. + /// public Vector2 Column1 { get { return new Vector2(Row0.Y, Row1.Y); } set { Row0.Y = value.X; Row1.Y = value.Y; } } + /// + /// Gets or sets the third column of the matrix. + /// public Vector2 Column2 { get { return new Vector2(Row0.Z, Row1.Z); } set { Row0.Z = value.X; Row1.Z = value.Y; } } + /// + /// Gets or sets the fourth column of the matrix. + /// public Vector2 Column3 { get { return new Vector2(Row0.W, Row1.W); } set { Row0.W = value.X; Row1.W = value.Y; } } + /// + /// Gets or sets the value at row 1, column 1 of this instance. + /// public float M11 { get { return Row0.X; } set { Row0.X = value; } } + + /// + /// Gets or sets the value at row 1, column 2 of this instance. + /// public float M12 { get { return Row0.Y; } set { Row0.Y = value; } } + + /// + /// Gets or sets the value at row 1, column 3 of this instance. + /// public float M13 { get { return Row0.Z; } set { Row0.Z = value; } } + + /// + /// Gets or sets the value at row 1, column 4 of this instance. + /// public float M14 { get { return Row0.W; } set { Row0.W = value; } } + + /// + /// Gets or sets the value at row 2, column 1 of this instance. + /// public float M21 { get { return Row1.X; } set { Row1.X = value; } } + + /// + /// Gets or sets the value at row 2, column 2 of this instance. + /// public float M22 { get { return Row1.Y; } set { Row1.Y = value; } } + + /// + /// Gets or sets the value at row 2, column 3 of this instance. + /// public float M23 { get { return Row1.Z; } set { Row1.Z = value; } } + + /// + /// Gets or sets the value at row 2, column 4 of this instance. + /// public float M24 { get { return Row1.W; } set { Row1.W = value; } } #endregion @@ -488,10 +534,6 @@ namespace OpenTK #endregion - #region Invert Functions - - #endregion - #region Transpose /// @@ -681,6 +723,11 @@ namespace OpenTK #region IEquatable Members + /// + /// Indicates whether the current matrix is equal to another matrix. + /// + /// An matrix to compare with this matrix. + /// true if the current matrix is equal to the matrix parameter; otherwise, false. public bool Equals(Matrix2x4 other) { return diff --git a/Source/OpenTK/Math/Matrix3.cs b/Source/OpenTK/Math/Matrix3.cs index 10423c37..efd0a895 100644 --- a/Source/OpenTK/Math/Matrix3.cs +++ b/Source/OpenTK/Math/Matrix3.cs @@ -439,7 +439,7 @@ namespace OpenTK /// Scale factor for the x axis. /// Scale factor for the y axis. /// Scale factor for the z axis. - /// A scale matrix. + /// A scale matrix. public static void CreateScale(float x, float y, float z, out Matrix3 result) { result = Identity; diff --git a/Source/OpenTK/Math/Matrix3d.cs b/Source/OpenTK/Math/Matrix3d.cs index 93607af1..788462cf 100644 --- a/Source/OpenTK/Math/Matrix3d.cs +++ b/Source/OpenTK/Math/Matrix3d.cs @@ -435,7 +435,7 @@ namespace OpenTK /// Scale factor for the x axis. /// Scale factor for the y axis. /// Scale factor for the z axis. - /// A scale matrix. + /// A scale matrix. public static void CreateScale(double x, double y, double z, out Matrix3d result) { result = Identity; diff --git a/Source/OpenTK/Math/Matrix3x2.cs b/Source/OpenTK/Math/Matrix3x2.cs index 15d039ad..759aca9c 100644 --- a/Source/OpenTK/Math/Matrix3x2.cs +++ b/Source/OpenTK/Math/Matrix3x2.cs @@ -27,6 +27,9 @@ using System.Runtime.InteropServices; namespace OpenTK { + /// + /// Represents a 3x2 matrix. + /// public struct Matrix3x2 : IEquatable { #region Fields @@ -93,23 +96,52 @@ namespace OpenTK #region Properties + /// + /// Gets or sets the first column of this matrix. + /// public Vector3 Column0 { get { return new Vector3(Row0.X, Row1.X, Row2.X); } set { Row0.X = value.X; Row1.X = value.Y; Row2.X = value.Z; } } + /// + /// Gets or sets the second column of this matrix. + /// public Vector3 Column1 { get { return new Vector3(Row0.Y, Row1.Y, Row2.Y); } set { Row0.Y = value.X; Row1.Y = value.Y; Row2.Y = value.Z; } } + /// + /// Gets or sets the value at row 1, column 1 of this instance. + /// public float M11 { get { return Row0.X; } set { Row0.X = value; } } + + /// + /// Gets or sets the value at row 1, column 2 of this instance. + /// public float M12 { get { return Row0.Y; } set { Row0.Y = value; } } + + /// + /// Gets or sets the value at row 2, column 1 of this instance. + /// public float M21 { get { return Row1.X; } set { Row1.X = value; } } + + /// + /// Gets or sets the value at row 2, column 2 of this instance. + /// public float M22 { get { return Row1.Y; } set { Row1.Y = value; } } + + /// + /// Gets or sets the value at row 3, column 1 of this instance. + /// public float M31 { get { return Row2.X; } set { Row2.X = value; } } + + /// + /// Gets or sets the value at row 3, column 2 of this instance. + /// public float M32 { get { return Row2.Y; } set { Row2.Y = value; } } #endregion @@ -478,10 +510,6 @@ namespace OpenTK #endregion - #region Invert Functions - - #endregion - #region Transpose /// @@ -669,6 +697,11 @@ namespace OpenTK #region IEquatable Members + /// + /// Indicates whether the current matrix is equal to another matrix. + /// + /// An matrix to compare with this matrix. + /// true if the current matrix is equal to the matrix parameter; otherwise, false. public bool Equals(Matrix3x2 other) { return diff --git a/Source/OpenTK/Math/Matrix3x4.cs b/Source/OpenTK/Math/Matrix3x4.cs index 7abb7d7f..418d7dba 100644 --- a/Source/OpenTK/Math/Matrix3x4.cs +++ b/Source/OpenTK/Math/Matrix3x4.cs @@ -832,7 +832,9 @@ namespace OpenTK #region IEquatable Members - /// Indicates whether the current matrix is equal to another matrix. + /// + /// Indicates whether the current matrix is equal to another matrix. + /// /// An matrix to compare with this matrix. /// true if the current matrix is equal to the matrix parameter; otherwise, false. public bool Equals(Matrix3x4 other) diff --git a/Source/OpenTK/Math/Matrix4.cs b/Source/OpenTK/Math/Matrix4.cs index 858cf462..8bd12347 100644 --- a/Source/OpenTK/Math/Matrix4.cs +++ b/Source/OpenTK/Math/Matrix4.cs @@ -630,7 +630,7 @@ namespace OpenTK /// Scale factor for the x axis. /// Scale factor for the y axis. /// Scale factor for the z axis. - /// A scale matrix. + /// A scale matrix. public static void CreateScale(float x, float y, float z, out Matrix4 result) { result = Identity; diff --git a/Source/OpenTK/Math/Matrix4x2.cs b/Source/OpenTK/Math/Matrix4x2.cs index 8d6f95c1..4ad57d56 100644 --- a/Source/OpenTK/Math/Matrix4x2.cs +++ b/Source/OpenTK/Math/Matrix4x2.cs @@ -108,25 +108,62 @@ namespace OpenTK #region Properties + /// + /// Gets or sets the first column of this matrix. + /// public Vector4 Column0 { get { return new Vector4(Row0.X, Row1.X, Row2.X, Row3.X); } set { Row0.X = value.X; Row1.X = value.Y; Row2.X = value.Z; Row3.X = value.W; } } + /// + /// Gets or sets the second column of this matrix. + /// public Vector4 Column1 { get { return new Vector4(Row0.Y, Row1.Y, Row2.Y, Row3.X); } set { Row0.Y = value.X; Row1.Y = value.Y; Row2.Y = value.Z; Row3.Y = value.W; } } + /// + /// Gets or sets the value at row 1, column 1 of this instance. + /// public float M11 { get { return Row0.X; } set { Row0.X = value; } } + + /// + /// Gets or sets the value at row 1, column 2 of this instance. + /// public float M12 { get { return Row0.Y; } set { Row0.Y = value; } } + + /// + /// Gets or sets the value at row 2, column 1 of this instance. + /// public float M21 { get { return Row1.X; } set { Row1.X = value; } } + + /// + /// Gets or sets the value at row 2, column 2 of this instance. + /// public float M22 { get { return Row1.Y; } set { Row1.Y = value; } } + + /// + /// Gets or sets the value at row 3, column 1 of this instance. + /// public float M31 { get { return Row2.X; } set { Row2.X = value; } } + + /// + /// Gets or sets the value at row 3, column 2 of this instance. + /// public float M32 { get { return Row2.Y; } set { Row2.Y = value; } } + + /// + /// Gets or sets the value at row 4, column 1 of this instance. + /// public float M41 { get { return Row3.X; } set { Row3.X = value; } } + + /// + /// Gets or sets the value at row 4, column 2 of this instance. + /// public float M42 { get { return Row3.Y; } set { Row3.Y = value; } } #endregion @@ -360,28 +397,302 @@ namespace OpenTK return result; } + /// + /// Multiplies two instances. + /// + /// The left operand of the multiplication. + /// The right operand of the multiplication. + /// A new instance that is the result of the multiplication. + public static void Mult(ref Matrix4x2 left, ref Matrix2x3 right, out Matrix4x3 result) + { + float lM11 = left.Row0.X, lM12 = left.Row0.Y, + lM21 = left.Row1.X, lM22 = left.Row1.Y, + lM31 = left.Row2.X, lM32 = left.Row2.Y, + lM41 = left.Row3.X, lM42 = left.Row3.Y, + rM11 = right.Row0.X, rM12 = right.Row0.Y, rM13 = right.Row0.Z, + rM21 = right.Row1.X, rM22 = right.Row1.Y, rM23 = right.Row1.Z; + + result.Row0.X = (lM11 * rM11) + (lM12 * rM21); + result.Row0.Y = (lM11 * rM12) + (lM12 * rM22); + result.Row0.Z = (lM11 * rM13) + (lM12 * rM23); + result.Row1.X = (lM21 * rM11) + (lM22 * rM21); + result.Row1.Y = (lM21 * rM12) + (lM22 * rM22); + result.Row1.Z = (lM21 * rM13) + (lM22 * rM23); + result.Row2.X = (lM31 * rM11) + (lM32 * rM21); + result.Row2.Y = (lM31 * rM12) + (lM32 * rM22); + result.Row2.Z = (lM31 * rM13) + (lM32 * rM23); + result.Row3.X = (lM41 * rM11) + (lM42 * rM21); + result.Row3.Y = (lM41 * rM12) + (lM42 * rM22); + result.Row3.Z = (lM41 * rM13) + (lM42 * rM23); + } + + /// + /// Multiplies two instances. + /// + /// The left operand of the multiplication. + /// The right operand of the multiplication. + /// A new instance that is the result of the multiplication. + public static Matrix4x3 Mult(Matrix4x2 left, Matrix2x3 right) + { + Matrix4x3 result; + Mult(ref left, ref right, out result); + return result; + } + + /// + /// Multiplies two instances. + /// + /// The left operand of the multiplication. + /// The right operand of the multiplication. + /// A new instance that is the result of the multiplication. + public static void Mult(ref Matrix4x2 left, ref Matrix2x4 right, out Matrix4 result) + { + float lM11 = left.Row0.X, lM12 = left.Row0.Y, + lM21 = left.Row1.X, lM22 = left.Row1.Y, + lM31 = left.Row2.X, lM32 = left.Row2.Y, + lM41 = left.Row3.X, lM42 = left.Row3.Y, + rM11 = right.Row0.X, rM12 = right.Row0.Y, rM13 = right.Row0.Z, rM14 = right.Row0.W, + rM21 = right.Row1.X, rM22 = right.Row1.Y, rM23 = right.Row1.Z, rM24 = right.Row1.W; + + result.Row0.X = (lM11 * rM11) + (lM12 * rM21); + result.Row0.Y = (lM11 * rM12) + (lM12 * rM22); + result.Row0.Z = (lM11 * rM13) + (lM12 * rM23); + result.Row0.W = (lM11 * rM14) + (lM12 * rM24); + result.Row1.X = (lM21 * rM11) + (lM22 * rM21); + result.Row1.Y = (lM21 * rM12) + (lM22 * rM22); + result.Row1.Z = (lM21 * rM13) + (lM22 * rM23); + result.Row1.W = (lM21 * rM14) + (lM22 * rM24); + result.Row2.X = (lM31 * rM11) + (lM32 * rM21); + result.Row2.Y = (lM31 * rM12) + (lM32 * rM22); + result.Row2.Z = (lM31 * rM13) + (lM32 * rM23); + result.Row2.W = (lM31 * rM14) + (lM32 * rM24); + result.Row3.X = (lM41 * rM11) + (lM42 * rM21); + result.Row3.Y = (lM41 * rM12) + (lM42 * rM22); + result.Row3.Z = (lM41 * rM13) + (lM42 * rM23); + result.Row3.W = (lM41 * rM14) + (lM42 * rM24); + } + + /// + /// Multiplies two instances. + /// + /// The left operand of the multiplication. + /// The right operand of the multiplication. + /// A new instance that is the result of the multiplication. + public static Matrix4 Mult(Matrix4x2 left, Matrix2x4 right) + { + Matrix4 result; + Mult(ref left, ref right, out result); + return result; + } + #endregion #region Add - #endregion + /// + /// Adds two instances. + /// + /// The left operand of the addition. + /// The right operand of the addition. + /// A new instance that is the result of the addition. + public static void Add(ref Matrix4x2 left, ref Matrix4x2 right, out Matrix4x2 result) + { + result.Row0.X = left.Row0.X + right.Row0.X; + result.Row0.Y = left.Row0.Y + right.Row0.Y; + result.Row1.X = left.Row1.X + right.Row1.X; + result.Row1.Y = left.Row1.Y + right.Row1.Y; + result.Row2.X = left.Row2.X + right.Row2.X; + result.Row2.Y = left.Row2.Y + right.Row2.Y; + result.Row3.X = left.Row3.X + right.Row3.X; + result.Row3.Y = left.Row3.Y + right.Row3.Y; + } - #region Subtact + /// + /// Adds two instances. + /// + /// The left operand of the addition. + /// The right operand of the addition. + /// A new instance that is the result of the addition. + public static Matrix4x2 Add(Matrix4x2 left, Matrix4x2 right) + { + Matrix4x2 result; + Add(ref left, ref right, out result); + return result; + } #endregion - #region Invert Functions + #region Subtract + + /// + /// Subtracts two instances. + /// + /// The left operand of the subtraction. + /// The right operand of the subtraction. + /// A new instance that is the result of the subtraction. + public static void Subtract(ref Matrix4x2 left, ref Matrix4x2 right, out Matrix4x2 result) + { + result.Row0.X = left.Row0.X - right.Row0.X; + result.Row0.Y = left.Row0.Y - right.Row0.Y; + result.Row1.X = left.Row1.X - right.Row1.X; + result.Row1.Y = left.Row1.Y - right.Row1.Y; + result.Row2.X = left.Row2.X - right.Row2.X; + result.Row2.Y = left.Row2.Y - right.Row2.Y; + result.Row3.X = left.Row3.X - right.Row3.X; + result.Row3.Y = left.Row3.Y - right.Row3.Y; + } + + /// + /// Subtracts two instances. + /// + /// The left operand of the subtraction. + /// The right operand of the subtraction. + /// A new instance that is the result of the subtraction. + public static Matrix4x2 Subtract(Matrix4x2 left, Matrix4x2 right) + { + Matrix4x2 result; + Subtract(ref left, ref right, out result); + return result; + } #endregion #region Transpose + /// + /// Calculate the transpose of the given matrix. + /// + /// The matrix to transpose. + /// The transpose of the given matrix. + public static void Transpose(ref Matrix4x2 mat, out Matrix2x4 result) + { + result.Row0.X = mat.Row0.X; + result.Row0.Y = mat.Row1.X; + result.Row0.Z = mat.Row2.X; + result.Row0.W = mat.Row3.X; + result.Row1.X = mat.Row0.Y; + result.Row1.Y = mat.Row1.Y; + result.Row1.Z = mat.Row2.Y; + result.Row1.W = mat.Row3.Y; + } + + /// + /// Calculate the transpose of the given matrix. + /// + /// The matrix to transpose. + /// The transpose of the given matrix. + public static Matrix2x4 Transpose(Matrix4x2 mat) + { + Matrix2x4 result; + Transpose(ref mat, out result); + return result; + } + #endregion #endregion #region Operators + /// + /// Scalar multiplication. + /// + /// left-hand operand + /// right-hand operand + /// A new Matrix4x2 which holds the result of the multiplication + public static Matrix4x2 operator *(float left, Matrix4x2 right) + { + return Mult(right, left); + } + + /// + /// Scalar multiplication. + /// + /// left-hand operand + /// right-hand operand + /// A new Matrix4x2 which holds the result of the multiplication + public static Matrix4x2 operator *(Matrix4x2 left, float right) + { + return Mult(left, right); + } + + /// + /// Matrix multiplication + /// + /// left-hand operand + /// right-hand operand + /// A new Matrix2 which holds the result of the multiplication + public static Matrix4x2 operator *(Matrix4x2 left, Matrix2 right) + { + return Mult(left, right); + } + + /// + /// Matrix multiplication + /// + /// left-hand operand + /// right-hand operand + /// A new Matrix4x3 which holds the result of the multiplication + public static Matrix4x3 operator *(Matrix4x2 left, Matrix2x3 right) + { + return Mult(left, right); + } + + /// + /// Matrix multiplication + /// + /// left-hand operand + /// right-hand operand + /// A new Matrix4 which holds the result of the multiplication + public static Matrix4 operator *(Matrix4x2 left, Matrix2x4 right) + { + return Mult(left, right); + } + + /// + /// Matrix addition + /// + /// left-hand operand + /// right-hand operand + /// A new Matrix4x2 which holds the result of the addition + public static Matrix4x2 operator +(Matrix4x2 left, Matrix4x2 right) + { + return Add(left, right); + } + + /// + /// Matrix subtraction + /// + /// left-hand operand + /// right-hand operand + /// A new Matrix4x2 which holds the result of the subtraction + public static Matrix4x2 operator -(Matrix4x2 left, Matrix4x2 right) + { + return Subtract(left, right); + } + + /// + /// Compares two instances for equality. + /// + /// The first instance. + /// The second instance. + /// True, if left equals right; false otherwise. + public static bool operator ==(Matrix4x2 left, Matrix4x2 right) + { + return left.Equals(right); + } + + /// + /// Compares two instances for inequality. + /// + /// The first instance. + /// The second instance. + /// True, if left does not equal right; false otherwise. + public static bool operator !=(Matrix4x2 left, Matrix4x2 right) + { + return !left.Equals(right); + } + #endregion #region Overrides @@ -435,6 +746,11 @@ namespace OpenTK #region IEquatable Members + /// + /// Indicates whether the current matrix is equal to another matrix. + /// + /// An matrix to compare with this matrix. + /// true if the current matrix is equal to the matrix parameter; otherwise, false. public bool Equals(Matrix4x2 other) { return diff --git a/Source/OpenTK/Math/Matrix4x3.cs b/Source/OpenTK/Math/Matrix4x3.cs index a9a39e08..af57a1d9 100644 --- a/Source/OpenTK/Math/Matrix4x3.cs +++ b/Source/OpenTK/Math/Matrix4x3.cs @@ -28,7 +28,7 @@ using System.Runtime.InteropServices; namespace OpenTK { /// - /// Represents a 3x4 Matrix + /// Represents a 3x4 matrix. /// [Serializable] [StructLayout(LayoutKind.Sequential)] @@ -70,7 +70,7 @@ namespace OpenTK /// /// Top row of the matrix /// Second row of the matrix - /// Third row of the matrix + /// Third row of the matrix /// Bottom row of the matrix public Matrix4x3(Vector3 row0, Vector3 row1, Vector3 row2, Vector3 row3) { @@ -804,6 +804,10 @@ namespace OpenTK #region public override string ToString() + /// + /// Returns a System.String that represents the current Matrix4x3. + /// + /// The string representation of the matrix. public override string ToString() { return string.Format("{0}\n{1}\n{2}", Row0, Row1, Row2); @@ -813,6 +817,10 @@ namespace OpenTK #region public override int GetHashCode() + /// + /// Returns the hashcode for this instance. + /// + /// A System.Int32 containing the unique hashcode for this instance. public override int GetHashCode() { return Row0.GetHashCode() ^ Row1.GetHashCode() ^ Row2.GetHashCode(); @@ -822,6 +830,11 @@ namespace OpenTK #region public override bool Equals(object obj) + /// + /// Indicates whether this instance and a specified object are equal. + /// + /// The object to compare tresult. + /// True if the instances are equal; false otherwise. public override bool Equals(object obj) { if (!(obj is Matrix4x3))