Skip to content

Commit

Permalink
A couple more maths functions
Browse files Browse the repository at this point in the history
  • Loading branch information
Artfunkel committed Feb 23, 2013
1 parent 11114ca commit b20b21d
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 2 deletions.
14 changes: 13 additions & 1 deletion Source/OpenTK/Math/Matrix4.cs
Expand Up @@ -280,6 +280,17 @@ public void Normalize()
Row2.Xyz = Row2.Xyz.Normalized();
}

/// <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>
Expand Down Expand Up @@ -343,7 +354,8 @@ public Quaternion RotationPart
q.Y = (float)((Row2[1] + Row1[2]) * sq);
}

return q.Normalized();
q.Normalize();
return q;
}
}

Expand Down
13 changes: 12 additions & 1 deletion Source/OpenTK/Math/Quaternion.cs
Expand Up @@ -192,14 +192,25 @@ public float LengthSquared
/// <summary>
/// Returns a copy of the Quaternion scaled to unit length.
/// </summary>
/// <returns></returns>
public Quaternion Normalized()
{
Quaternion q = this;
q.Normalize();
return q;
}

public void Invert()
{
W = -W;
}

public Quaternion Inverted()
{
var q = this;
q.Invert();
return q;
}

#region public void Normalize()

/// <summary>
Expand Down

0 comments on commit b20b21d

Please sign in to comment.