diff --git a/Source/OpenTK/Math/Matrix3.cs b/Source/OpenTK/Math/Matrix3.cs
index 3fb8e2e5..e4d71661 100644
--- a/Source/OpenTK/Math/Matrix3.cs
+++ b/Source/OpenTK/Math/Matrix3.cs
@@ -287,6 +287,29 @@ namespace OpenTK
return m;
}
+ ///
+ /// Returns a copy of this Matrix3 without scale.
+ ///
+ public Matrix3 ClearScale()
+ {
+ Matrix3 m = this;
+ m.Row0 = m.Row0.Normalized();
+ m.Row1 = m.Row1.Normalized();
+ m.Row2 = m.Row2.Normalized();
+ return m;
+ }
+ ///
+ /// Returns a copy of this Matrix3 without rotation.
+ ///
+ public Matrix3 ClearRotation()
+ {
+ Matrix3 m = this;
+ m.Row0 = new Vector3(m.Row0.Length, 0, 0);
+ m.Row1 = new Vector3(0, m.Row1.Length, 0);
+ m.Row2 = new Vector3(0, 0, m.Row2.Length);
+ return m;
+ }
+
///
/// Returns the scale component of this instance.
///
diff --git a/Source/OpenTK/Math/Matrix3d.cs b/Source/OpenTK/Math/Matrix3d.cs
index d98da9c9..6d0fc064 100644
--- a/Source/OpenTK/Math/Matrix3d.cs
+++ b/Source/OpenTK/Math/Matrix3d.cs
@@ -283,6 +283,30 @@ namespace OpenTK
return m;
}
+
+ ///
+ /// Returns a copy of this Matrix3 without scale.
+ ///
+ public Matrix3d ClearScale()
+ {
+ Matrix3d m = this;
+ m.Row0 = m.Row0.Normalized();
+ m.Row1 = m.Row1.Normalized();
+ m.Row2 = m.Row2.Normalized();
+ return m;
+ }
+ ///
+ /// Returns a copy of this Matrix3 without rotation.
+ ///
+ public Matrix3d ClearRotation()
+ {
+ Matrix3d m = this;
+ m.Row0 = new Vector3d(m.Row0.Length, 0, 0);
+ m.Row1 = new Vector3d(0, m.Row1.Length, 0);
+ m.Row2 = new Vector3d(0, 0, m.Row2.Length);
+ return m;
+ }
+
///
/// Returns the scale component of this instance.
///
diff --git a/Source/OpenTK/Math/Matrix4.cs b/Source/OpenTK/Math/Matrix4.cs
index 756c1e22..ebb10ad2 100644
--- a/Source/OpenTK/Math/Matrix4.cs
+++ b/Source/OpenTK/Math/Matrix4.cs
@@ -349,6 +349,47 @@ namespace OpenTK
return m;
}
+ ///
+ /// Returns a copy of this Matrix4 without translation.
+ ///
+ public Matrix4 ClearTranslation()
+ {
+ Matrix4 m = this;
+ m.Row3.Xyz = Vector3.Zero;
+ return m;
+ }
+ ///
+ /// Returns a copy of this Matrix4 without scale.
+ ///
+ public Matrix4 ClearScale()
+ {
+ Matrix4 m = this;
+ m.Row0.Xyz = m.Row0.Xyz.Normalized();
+ m.Row1.Xyz = m.Row1.Xyz.Normalized();
+ m.Row2.Xyz = m.Row2.Xyz.Normalized();
+ return m;
+ }
+ ///
+ /// Returns a copy of this Matrix4 without rotation.
+ ///
+ public Matrix4 ClearRotation()
+ {
+ Matrix4 m = this;
+ m.Row0.Xyz = new Vector3(m.Row0.Xyz.Length, 0, 0);
+ m.Row1.Xyz = new Vector3(0, m.Row1.Xyz.Length, 0);
+ m.Row2.Xyz = new Vector3(0, 0, m.Row2.Xyz.Length);
+ return m;
+ }
+ ///
+ /// Returns a copy of this Matrix4 without projection.
+ ///
+ public Matrix4 ClearProjection()
+ {
+ Matrix4 m = this;
+ m.Column3 = Vector4.Zero;
+ return m;
+ }
+
///
/// Returns the translation component of this instance.
///
@@ -357,7 +398,7 @@ namespace OpenTK
///
/// Returns the scale component of this instance.
///
- public Vector3 ExtractScale() { return new Vector3(Row0.Length, Row1.Length, Row2.Length); }
+ public Vector3 ExtractScale() { return new Vector3(Row0.Xyz.Length, Row1.Xyz.Length, Row2.Xyz.Length); }
///
/// Returns the rotation component of this instance. Quite slow.
@@ -426,6 +467,14 @@ namespace OpenTK
return q;
}
+ ///
+ /// Returns the projection component of this instance.
+ ///
+ public Vector4 ExtractProjection()
+ {
+ return Column3;
+ }
+
#endregion
#region Static
diff --git a/Source/OpenTK/Math/Matrix4d.cs b/Source/OpenTK/Math/Matrix4d.cs
index 108c9ff5..544d43b4 100644
--- a/Source/OpenTK/Math/Matrix4d.cs
+++ b/Source/OpenTK/Math/Matrix4d.cs
@@ -138,6 +138,7 @@ namespace OpenTK
public Vector4d Column0
{
get { return new Vector4d (Row0.X, Row1.X, Row2.X, Row3.X); }
+ set { Row0.X = value.X; Row1.X = value.Y; Row2.X = value.Z; Row3.X = value.W; }
}
///
@@ -146,6 +147,7 @@ namespace OpenTK
public Vector4d Column1
{
get { return new Vector4d (Row0.Y, Row1.Y, Row2.Y, Row3.Y); }
+ set { Row0.Y = value.X; Row1.Y = value.Y; Row2.Y = value.Z; Row3.Y = value.W; }
}
///
@@ -154,6 +156,7 @@ namespace OpenTK
public Vector4d Column2
{
get { return new Vector4d (Row0.Z, Row1.Z, Row2.Z, Row3.Z); }
+ set { Row0.Z = value.X; Row1.Z = value.Y; Row2.Z = value.Z; Row3.Z = value.W; }
}
///
@@ -162,6 +165,7 @@ namespace OpenTK
public Vector4d Column3
{
get { return new Vector4d (Row0.W, Row1.W, Row2.W, Row3.W); }
+ set { Row0.W = value.X; Row1.W = value.Y; Row2.W = value.Z; Row3.W = value.W; }
}
///
@@ -332,6 +336,47 @@ namespace OpenTK
return m;
}
+ ///
+ /// Returns a copy of this Matrix4d without translation.
+ ///
+ public Matrix4d ClearTranslation()
+ {
+ Matrix4d m = this;
+ m.Row3.Xyz = Vector3d.Zero;
+ return m;
+ }
+ ///
+ /// Returns a copy of this Matrix4d without scale.
+ ///
+ public Matrix4d ClearScale()
+ {
+ Matrix4d m = this;
+ m.Row0.Xyz = m.Row0.Xyz.Normalized();
+ m.Row1.Xyz = m.Row1.Xyz.Normalized();
+ m.Row2.Xyz = m.Row2.Xyz.Normalized();
+ return m;
+ }
+ ///
+ /// Returns a copy of this Matrix4d without rotation.
+ ///
+ public Matrix4d ClearRotation()
+ {
+ Matrix4d m = this;
+ m.Row0.Xyz = new Vector3d(m.Row0.Xyz.Length, 0, 0);
+ m.Row1.Xyz = new Vector3d(0, m.Row1.Xyz.Length, 0);
+ m.Row2.Xyz = new Vector3d(0, 0, m.Row2.Xyz.Length);
+ return m;
+ }
+ ///
+ /// Returns a copy of this Matrix4d without projection.
+ ///
+ public Matrix4d ClearProjection()
+ {
+ Matrix4d m = this;
+ m.Column3 = Vector4d.Zero;
+ return m;
+ }
+
///
/// Returns the translation component of this instance.
///
@@ -340,7 +385,7 @@ namespace OpenTK
///
/// Returns the scale component of this instance.
///
- public Vector3d ExtractScale() { return new Vector3d(Row0.Length, Row1.Length, Row2.Length); }
+ public Vector3d ExtractScale() { return new Vector3d(Row0.Xyz.Length, Row1.Xyz.Length, Row2.Xyz.Length); }
///
/// Returns the rotation component of this instance. Quite slow.
@@ -409,6 +454,15 @@ namespace OpenTK
return q;
}
+ ///
+ /// Returns the projection component of this instance.
+ ///
+ public Vector4d ExtractProjection()
+ {
+ return Column3;
+ }
+
+
#endregion
#region Static