From 7a4dfcf40dec14e1193f6e22c92a3b4e930e22bb Mon Sep 17 00:00:00 2001 From: Robert Rouhani Date: Thu, 11 Sep 2014 12:33:34 -0400 Subject: [PATCH] Changed Matrix4[d].CreateFromRotationMatrix to a new constructor. --- Source/OpenTK/Math/Matrix4.cs | 55 +++++++++++++++------------------- Source/OpenTK/Math/Matrix4d.cs | 55 +++++++++++++++------------------- 2 files changed, 48 insertions(+), 62 deletions(-) diff --git a/Source/OpenTK/Math/Matrix4.cs b/Source/OpenTK/Math/Matrix4.cs index 18282989..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 @@ -592,37 +616,6 @@ namespace OpenTK #endregion - #region CreateFromRotationMatrix - - public static Matrix4 CreateFromRotationMatrix(Matrix3 rotation) - { - Matrix4 result; - CreateFromRotationMatrix(ref rotation, out result); - return result; - } - - public static void CreateFromRotationMatrix(ref Matrix3 rotation, out Matrix4 result) - { - result.Row0.X = rotation.Row0.X; - result.Row0.Y = rotation.Row0.Y; - result.Row0.Z = rotation.Row0.Z; - result.Row0.W = 0; - result.Row1.X = rotation.Row1.X; - result.Row1.Y = rotation.Row1.Y; - result.Row1.Z = rotation.Row1.Z; - result.Row1.W = 0; - result.Row2.X = rotation.Row2.X; - result.Row2.Y = rotation.Row2.Y; - result.Row2.Z = rotation.Row2.Z; - result.Row2.W = 0; - result.Row3.X = 0; - result.Row3.Y = 0; - result.Row3.Z = 0; - result.Row3.W = 1; - } - - #endregion - #region CreateRotation[XYZ] /// diff --git a/Source/OpenTK/Math/Matrix4d.cs b/Source/OpenTK/Math/Matrix4d.cs index 103b94ae..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 @@ -551,37 +575,6 @@ namespace OpenTK #endregion - #region CreateFromRotationMatrix - - public static Matrix4d CreateFromRotationMatrix(Matrix3d rotation) - { - Matrix4d result; - CreateFromRotationMatrix(ref rotation, out result); - return result; - } - - public static void CreateFromRotationMatrix(ref Matrix3d rotation, out Matrix4d result) - { - result.Row0.X = rotation.Row0.X; - result.Row0.Y = rotation.Row0.Y; - result.Row0.Z = rotation.Row0.Z; - result.Row0.W = 0; - result.Row1.X = rotation.Row1.X; - result.Row1.Y = rotation.Row1.Y; - result.Row1.Z = rotation.Row1.Z; - result.Row1.W = 0; - result.Row2.X = rotation.Row2.X; - result.Row2.Y = rotation.Row2.Y; - result.Row2.Z = rotation.Row2.Z; - result.Row2.W = 0; - result.Row3.X = 0; - result.Row3.Y = 0; - result.Row3.Z = 0; - result.Row3.W = 1; - } - - #endregion - #region CreateRotation[XYZ] ///