diff --git a/Source/OpenTK/Math/Quaternion.cs b/Source/OpenTK/Math/Quaternion.cs
index 8e9fbcdd..da62d7c4 100644
--- a/Source/OpenTK/Math/Quaternion.cs
+++ b/Source/OpenTK/Math/Quaternion.cs
@@ -296,6 +296,7 @@ namespace OpenTK
/// The first instance.
/// The second instance.
/// A new instance containing the result of the calculation.
+ [Obsolete("Use Multiply instead.")]
public static Quaternion Mult(Quaternion left, Quaternion right)
{
return new Quaternion(
@@ -309,6 +310,7 @@ namespace OpenTK
/// The first instance.
/// The second instance.
/// A new instance containing the result of the calculation.
+ [Obsolete("Use Multiply instead.")]
public static void Mult(ref Quaternion left, ref Quaternion right, out Quaternion result)
{
result = new Quaternion(
@@ -316,13 +318,39 @@ namespace OpenTK
left.W * right.W - Vector3.Dot(left.Xyz, right.Xyz));
}
+ ///
+ /// Multiplies two instances.
+ ///
+ /// The first instance.
+ /// The second instance.
+ /// A new instance containing the result of the calculation.
+ public static Quaternion Multiply(Quaternion left, Quaternion right)
+ {
+ Quaternion result;
+ Multiply(ref left, ref right, out result);
+ return result;
+ }
+
+ ///
+ /// Multiplies two instances.
+ ///
+ /// The first instance.
+ /// The second instance.
+ /// A new instance containing the result of the calculation.
+ public static void Multiply(ref Quaternion left, ref Quaternion right, out Quaternion result)
+ {
+ result = new Quaternion(
+ right.W * left.Xyz + left.W * right.Xyz + Vector3.Cross(left.Xyz, right.Xyz),
+ left.W * right.W - Vector3.Dot(left.Xyz, right.Xyz));
+ }
+
///
/// Multiplies an instance by a scalar.
///
/// The instance.
/// The scalar.
/// A new instance containing the result of the calculation.
- public static void Multiply(ref Quaternion quaternion, ref float scale, out Quaternion result)
+ public static void Multiply(ref Quaternion quaternion, float scale, out Quaternion result)
{
result = new Quaternion(quaternion.X * scale, quaternion.Y * scale, quaternion.Z * scale, quaternion.W * scale);
}
@@ -556,9 +584,7 @@ namespace OpenTK
/// The result of the calculation.
public static Quaternion operator *(Quaternion left, Quaternion right)
{
- float w = left.W * right.W - Vector3.Dot(left.Xyz, right.Xyz);
- left.Xyz = right.W * left.Xyz + left.W * right.Xyz + Vector3.Cross(left.Xyz, right.Xyz);
- left.W = w;
+ Multiply(ref left, ref right, out left);
return left;
}
@@ -570,7 +596,8 @@ namespace OpenTK
/// A new instance containing the result of the calculation.
public static Quaternion operator *(Quaternion quaternion, float scale)
{
- return new Quaternion(quaternion.X * scale, quaternion.Y * scale, quaternion.Z * scale, quaternion.W * scale);
+ Multiply(ref quaternion, scale, out quaternion);
+ return quaternion;
}
///
diff --git a/Source/OpenTK/Math/Quaterniond.cs b/Source/OpenTK/Math/Quaterniond.cs
index 75cbd908..c9820db4 100644
--- a/Source/OpenTK/Math/Quaterniond.cs
+++ b/Source/OpenTK/Math/Quaterniond.cs
@@ -296,6 +296,7 @@ namespace OpenTK
/// The first instance.
/// The second instance.
/// A new instance containing the result of the calculation.
+ [Obsolete("Use Multiply instead.")]
public static Quaterniond Mult(Quaterniond left, Quaterniond right)
{
return new Quaterniond(
@@ -309,6 +310,7 @@ namespace OpenTK
/// The first instance.
/// The second instance.
/// A new instance containing the result of the calculation.
+ [Obsolete("Use Multiply instead.")]
public static void Mult(ref Quaterniond left, ref Quaterniond right, out Quaterniond result)
{
result = new Quaterniond(
@@ -316,13 +318,39 @@ namespace OpenTK
left.W * right.W - Vector3d.Dot(left.Xyz, right.Xyz));
}
+ ///
+ /// Multiplies two instances.
+ ///
+ /// The first instance.
+ /// The second instance.
+ /// A new instance containing the result of the calculation.
+ public static Quaterniond Multiply(Quaterniond left, Quaterniond right)
+ {
+ Quaterniond result;
+ Multiply(ref left, ref right, out result);
+ return result;
+ }
+
+ ///
+ /// Multiplies two instances.
+ ///
+ /// The first instance.
+ /// The second instance.
+ /// A new instance containing the result of the calculation.
+ public static void Multiply(ref Quaterniond left, ref Quaterniond right, out Quaterniond result)
+ {
+ result = new Quaterniond(
+ right.W * left.Xyz + left.W * right.Xyz + Vector3d.Cross(left.Xyz, right.Xyz),
+ left.W * right.W - Vector3d.Dot(left.Xyz, right.Xyz));
+ }
+
///
/// Multiplies an instance by a scalar.
///
/// The instance.
/// The scalar.
/// A new instance containing the result of the calculation.
- public static void Multiply(ref Quaterniond quaternion, ref double scale, out Quaterniond result)
+ public static void Multiply(ref Quaterniond quaternion, double scale, out Quaterniond result)
{
result = new Quaterniond(quaternion.X * scale, quaternion.Y * scale, quaternion.Z * scale, quaternion.W * scale);
}
@@ -556,9 +584,7 @@ namespace OpenTK
/// The result of the calculation.
public static Quaterniond operator *(Quaterniond left, Quaterniond right)
{
- double w = left.W * right.W - Vector3d.Dot(left.Xyz, right.Xyz);
- left.Xyz = right.W * left.Xyz + left.W * right.Xyz + Vector3d.Cross(left.Xyz, right.Xyz);
- left.W = w;
+ Multiply(ref left, ref right, out left);
return left;
}
@@ -570,7 +596,8 @@ namespace OpenTK
/// A new instance containing the result of the calculation.
public static Quaterniond operator *(Quaterniond quaternion, double scale)
{
- return new Quaterniond(quaternion.X * scale, quaternion.Y * scale, quaternion.Z * scale, quaternion.W * scale);
+ Multiply(ref quaternion, scale, out quaternion);
+ return quaternion;
}
///