Added Matrix3[d].Add and Matrix4[d].CreateFromRotationMatrix
authorRobert Rouhani <robert.rouhani@gmail.com>
Tue, 9 Sep 2014 17:21:11 +0000 (13:21 -0400)
committerRobert Rouhani <robert.rouhani@gmail.com>
Tue, 9 Sep 2014 17:21:11 +0000 (13:21 -0400)
Source/OpenTK/Math/Matrix3.cs
Source/OpenTK/Math/Matrix3d.cs
Source/OpenTK/Math/Matrix4.cs
Source/OpenTK/Math/Matrix4d.cs

index cd2f3bc..18b5c6f 100644 (file)
@@ -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
 
         /// <summary>
index 757c36c..7963353 100644 (file)
@@ -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
 
         /// <summary>
index 2d311fd..1828298 100644 (file)
@@ -592,6 +592,37 @@ 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]
 
         /// <summary>
index 785a6a1..103b94a 100644 (file)
@@ -551,6 +551,37 @@ 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]
 
         /// <summary>