Deprecated Mult in favor of Multiply.

Modified operator * to use Multiply internally (reduces code duplication).
This commit is contained in:
the_fiddler 2009-11-03 12:11:51 +00:00
parent eeda1bf866
commit b5eb7fdb93
2 changed files with 64 additions and 10 deletions

View file

@ -296,6 +296,7 @@ namespace OpenTK
/// <param name="left">The first instance.</param>
/// <param name="right">The second instance.</param>
/// <returns>A new instance containing the result of the calculation.</returns>
[Obsolete("Use Multiply instead.")]
public static Quaternion Mult(Quaternion left, Quaternion right)
{
return new Quaternion(
@ -309,6 +310,7 @@ namespace OpenTK
/// <param name="left">The first instance.</param>
/// <param name="right">The second instance.</param>
/// <param name="result">A new instance containing the result of the calculation.</param>
[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));
}
/// <summary>
/// Multiplies two instances.
/// </summary>
/// <param name="left">The first instance.</param>
/// <param name="right">The second instance.</param>
/// <returns>A new instance containing the result of the calculation.</returns>
public static Quaternion Multiply(Quaternion left, Quaternion right)
{
Quaternion result;
Multiply(ref left, ref right, out result);
return result;
}
/// <summary>
/// Multiplies two instances.
/// </summary>
/// <param name="left">The first instance.</param>
/// <param name="right">The second instance.</param>
/// <param name="result">A new instance containing the result of the calculation.</param>
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));
}
/// <summary>
/// Multiplies an instance by a scalar.
/// </summary>
/// <param name="quaternion">The instance.</param>
/// <param name="scale">The scalar.</param>
/// <param name="result">A new instance containing the result of the calculation.</param>
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
/// <returns>The result of the calculation.</returns>
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
/// <returns>A new instance containing the result of the calculation.</returns>
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;
}
/// <summary>

View file

@ -296,6 +296,7 @@ namespace OpenTK
/// <param name="left">The first instance.</param>
/// <param name="right">The second instance.</param>
/// <returns>A new instance containing the result of the calculation.</returns>
[Obsolete("Use Multiply instead.")]
public static Quaterniond Mult(Quaterniond left, Quaterniond right)
{
return new Quaterniond(
@ -309,6 +310,7 @@ namespace OpenTK
/// <param name="left">The first instance.</param>
/// <param name="right">The second instance.</param>
/// <param name="result">A new instance containing the result of the calculation.</param>
[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));
}
/// <summary>
/// Multiplies two instances.
/// </summary>
/// <param name="left">The first instance.</param>
/// <param name="right">The second instance.</param>
/// <returns>A new instance containing the result of the calculation.</returns>
public static Quaterniond Multiply(Quaterniond left, Quaterniond right)
{
Quaterniond result;
Multiply(ref left, ref right, out result);
return result;
}
/// <summary>
/// Multiplies two instances.
/// </summary>
/// <param name="left">The first instance.</param>
/// <param name="right">The second instance.</param>
/// <param name="result">A new instance containing the result of the calculation.</param>
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));
}
/// <summary>
/// Multiplies an instance by a scalar.
/// </summary>
/// <param name="quaternion">The instance.</param>
/// <param name="scale">The scalar.</param>
/// <param name="result">A new instance containing the result of the calculation.</param>
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
/// <returns>The result of the calculation.</returns>
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
/// <returns>A new instance containing the result of the calculation.</returns>
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;
}
/// <summary>