From 94c7ad4f584c7cadff57514b22a46ac7419d4b15 Mon Sep 17 00:00:00 2001 From: Robert Rouhani Date: Sat, 26 Jan 2013 12:57:19 -0500 Subject: [PATCH] Implemented Matrix3(d) constructor that takes upper-left 3x3 of a Matrix4(d) as discussed in the following issue: https://github.com/andykorth/opentk/issues/4 --- Source/OpenTK/Math/Matrix3.cs | 11 +++++++++++ Source/OpenTK/Math/Matrix3d.cs | 13 ++++++++++++- 2 files changed, 23 insertions(+), 1 deletion(-) diff --git a/Source/OpenTK/Math/Matrix3.cs b/Source/OpenTK/Math/Matrix3.cs index efd0a895..74b34608 100644 --- a/Source/OpenTK/Math/Matrix3.cs +++ b/Source/OpenTK/Math/Matrix3.cs @@ -99,6 +99,17 @@ namespace OpenTK Row1 = new Vector3(m10, m11, m12); Row2 = new Vector3(m20, m21, m22); } + + /// + /// Constructs a new instnace. + /// + /// A Matrix4 to take the upper-left 3x3 from. + public Matrix3(Matrix4 matrix) + { + Row0 = matrix.Row0.Xyz; + Row1 = matrix.Row1.Xyz; + Row2 = matrix.Row2.Xyz; + } #endregion diff --git a/Source/OpenTK/Math/Matrix3d.cs b/Source/OpenTK/Math/Matrix3d.cs index 788462cf..d5657ba5 100644 --- a/Source/OpenTK/Math/Matrix3d.cs +++ b/Source/OpenTK/Math/Matrix3d.cs @@ -94,7 +94,18 @@ namespace OpenTK Row1 = new Vector3d(m10, m11, m12); Row2 = new Vector3d(m20, m21, m22); } - + + /// + /// Constructs a new instance. + /// + /// A Matrix4d to take the upper-left 3x3 from. + public Matrix3d(Matrix4d matrix) + { + Row0 = matrix.Row0.Xyz; + Row1 = matrix.Row1.Xyz; + Row2 = matrix.Row2.Xyz; + } + #endregion #region Public Members