diff --git a/Source/OpenTK/Math/Matrix3.cs b/Source/OpenTK/Math/Matrix3.cs index cd2f3bc7..18b5c6fb 100644 --- a/Source/OpenTK/Math/Matrix3.cs +++ b/Source/OpenTK/Math/Matrix3.cs @@ -667,7 +667,25 @@ namespace OpenTK } #endregion - + + #region Add Functions + + public static Matrix3 Add(Matrix3 left, Matrix3 right) + { + Matrix3 result; + Add(ref left, ref right, out result); + return result; + } + + public static void Add(ref Matrix3 left, ref Matrix3 right, out Matrix3 result) + { + Vector3.Add(ref left.Row0, ref right.Row0, out result.Row0); + Vector3.Add(ref left.Row1, ref right.Row1, out result.Row1); + Vector3.Add(ref left.Row2, ref right.Row2, out result.Row2); + } + + #endregion + #region Multiply Functions /// diff --git a/Source/OpenTK/Math/Matrix3d.cs b/Source/OpenTK/Math/Matrix3d.cs index 757c36ca..79633534 100644 --- a/Source/OpenTK/Math/Matrix3d.cs +++ b/Source/OpenTK/Math/Matrix3d.cs @@ -664,7 +664,25 @@ namespace OpenTK } #endregion - + + #region Add Functions + + public static Matrix3d Add(Matrix3d left, Matrix3d right) + { + Matrix3d result; + Add(ref left, ref right, out result); + return result; + } + + public static void Add(ref Matrix3d left, ref Matrix3d right, out Matrix3d result) + { + Vector3d.Add(ref left.Row0, ref right.Row0, out result.Row0); + Vector3d.Add(ref left.Row1, ref right.Row1, out result.Row1); + Vector3d.Add(ref left.Row2, ref right.Row2, out result.Row2); + } + + #endregion + #region Multiply Functions /// diff --git a/Source/OpenTK/Math/Matrix4.cs b/Source/OpenTK/Math/Matrix4.cs index 2d311fd5..945f367d 100644 --- a/Source/OpenTK/Math/Matrix4.cs +++ b/Source/OpenTK/Math/Matrix4.cs @@ -117,6 +117,30 @@ namespace OpenTK Row3 = new Vector4(m30, m31, m32, m33); } + /// + /// Constructs a new instance. + /// + /// The top left 3x3 of the matrix. + public Matrix4(Matrix3 topLeft) + { + Row0.X = topLeft.Row0.X; + Row0.Y = topLeft.Row0.Y; + Row0.Z = topLeft.Row0.Z; + Row0.W = 0; + Row1.X = topLeft.Row1.X; + Row1.Y = topLeft.Row1.Y; + Row1.Z = topLeft.Row1.Z; + Row1.W = 0; + Row2.X = topLeft.Row2.X; + Row2.Y = topLeft.Row2.Y; + Row2.Z = topLeft.Row2.Z; + Row2.W = 0; + Row3.X = 0; + Row3.Y = 0; + Row3.Z = 0; + Row3.W = 1; + } + #endregion #region Public Members diff --git a/Source/OpenTK/Math/Matrix4d.cs b/Source/OpenTK/Math/Matrix4d.cs index 785a6a12..8a2a2137 100644 --- a/Source/OpenTK/Math/Matrix4d.cs +++ b/Source/OpenTK/Math/Matrix4d.cs @@ -109,6 +109,30 @@ namespace OpenTK Row3 = new Vector4d(m30, m31, m32, m33); } + /// + /// Constructs a new instance. + /// + /// The top left 3x3 of the matrix. + public Matrix4d(Matrix3d topLeft) + { + Row0.X = topLeft.Row0.X; + Row0.Y = topLeft.Row0.Y; + Row0.Z = topLeft.Row0.Z; + Row0.W = 0; + Row1.X = topLeft.Row1.X; + Row1.Y = topLeft.Row1.Y; + Row1.Z = topLeft.Row1.Z; + Row1.W = 0; + Row2.X = topLeft.Row2.X; + Row2.Y = topLeft.Row2.Y; + Row2.Z = topLeft.Row2.Z; + Row2.W = 0; + Row3.X = 0; + Row3.Y = 0; + Row3.Z = 0; + Row3.W = 1; + } + #endregion #region Public Members