Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

A couple more maths functions

  • Loading branch information...
commit b20b21d22862a45055c695c8706c70a72559a5ae 1 parent 11114ca
@Artfunkel Artfunkel authored
Showing with 25 additions and 2 deletions.
  1. +13 −1 Source/OpenTK/Math/Matrix4.cs
  2. +12 −1 Source/OpenTK/Math/Quaternion.cs
View
14 Source/OpenTK/Math/Matrix4.cs
@@ -281,6 +281,17 @@ public void Normalize()
}
/// <summary>
+ /// Returns an inverted copy of this instance.
+ /// </summary>
+ public Matrix4 Inverted()
+ {
+ Matrix4 m = this;
+ if (m.Determinant != 0)
+ m.Invert();
+ return m;
+ }
+
+ /// <summary>
/// Gets the translation component of this instance.
/// </summary>
public Vector3 TranslationPart { get { return Row3.Xyz; } }
@@ -343,7 +354,8 @@ public Quaternion RotationPart
q.Y = (float)((Row2[1] + Row1[2]) * sq);
}
- return q.Normalized();
+ q.Normalize();
+ return q;
}
}
View
13 Source/OpenTK/Math/Quaternion.cs
@@ -192,7 +192,6 @@ public float LengthSquared
/// <summary>
/// Returns a copy of the Quaternion scaled to unit length.
/// </summary>
- /// <returns></returns>
public Quaternion Normalized()
{
Quaternion q = this;
@@ -200,6 +199,18 @@ public Quaternion Normalized()
return q;
}
+ public void Invert()
+ {
+ W = -W;
+ }
+
+ public Quaternion Inverted()
+ {
+ var q = this;
+ q.Invert();
+ return q;
+ }
+
#region public void Normalize()
/// <summary>

0 comments on commit b20b21d

Please sign in to comment.
Something went wrong with that request. Please try again.