Fixed two instances where the obsolete XYZ attribute was being used.

This commit is contained in:
the_fiddler 2009-02-22 12:09:23 +00:00
parent 824a751762
commit 6545358593
2 changed files with 113 additions and 113 deletions

View file

@ -45,27 +45,27 @@ namespace OpenTK.Math
#region Constructors #region Constructors
/// <summary> /// <summary>
/// Construct a new Quaternion from vector and w components /// Construct a new Quaternion from vector and w components
/// </summary> /// </summary>
/// <param name="v">The vector part</param> /// <param name="v">The vector part</param>
/// <param name="w">The w part</param> /// <param name="w">The w part</param>
public Quaternion(Vector3 v, float w) public Quaternion(Vector3 v, float w)
{ {
this.xyz = v; this.xyz = v;
this.w = w; this.w = w;
} }
/// <summary> /// <summary>
/// Construct a new Quaternion /// Construct a new Quaternion
/// </summary> /// </summary>
/// <param name="x">The x component</param> /// <param name="x">The x component</param>
/// <param name="y">The y component</param> /// <param name="y">The y component</param>
/// <param name="z">The z component</param> /// <param name="z">The z component</param>
/// <param name="w">The w component</param> /// <param name="w">The w component</param>
public Quaternion(float x, float y, float z, float w) public Quaternion(float x, float y, float z, float w)
: this(new Vector3(x, y, z), w) : this(new Vector3(x, y, z), w)
{ } { }
#endregion #endregion
@ -117,16 +117,16 @@ namespace OpenTK.Math
#region ToAxisAngle #region ToAxisAngle
/// <summary> /// <summary>
/// Convert the current quaternion to axis angle representation /// Convert the current quaternion to axis angle representation
/// </summary> /// </summary>
/// <param name="axis">The resultant axis</param> /// <param name="axis">The resultant axis</param>
/// <param name="angle">The resultant angle</param> /// <param name="angle">The resultant angle</param>
public void ToAxisAngle(out Vector3 axis, out float angle) public void ToAxisAngle(out Vector3 axis, out float angle)
{ {
Vector4 result = ToAxisAngle(); Vector4 result = ToAxisAngle();
axis = result.Xyz; axis = result.Xyz;
angle = result.W; angle = result.W;
} }
/// <summary> /// <summary>
/// Convert this instance to an axis-angle representation. /// Convert this instance to an axis-angle representation.
@ -156,34 +156,34 @@ namespace OpenTK.Math
return result; return result;
} }
#endregion #endregion
#region public float Length #region public float Length
/// <summary> /// <summary>
/// Gets the length (magnitude) of the quaternion. /// Gets the length (magnitude) of the quaternion.
/// </summary> /// </summary>
/// <seealso cref="LengthSquared"/> /// <seealso cref="LengthSquared"/>
public float Length public float Length
{ {
get get
{ {
return (float)System.Math.Sqrt(W * W + XYZ.LengthSquared); return (float)System.Math.Sqrt(W * W + Xyz.LengthSquared);
} }
} }
#endregion #endregion
#region public float LengthSquared #region public float LengthSquared
/// <summary> /// <summary>
/// Gets the square of the quaternion length (magnitude). /// Gets the square of the quaternion length (magnitude).
/// </summary> /// </summary>
public float LengthSquared public float LengthSquared
{ {
get get
{ {
return W * W + XYZ.LengthSquared; return W * W + Xyz.LengthSquared;
} }
} }
@ -203,19 +203,19 @@ namespace OpenTK.Math
#endregion #endregion
#region public void Conjugate() #region public void Conjugate()
/// <summary> /// <summary>
/// Convert this quaternion to its conjugate /// Convert this quaternion to its conjugate
/// </summary> /// </summary>
public void Conjugate() public void Conjugate()
{ {
Xyz = -Xyz; Xyz = -Xyz;
} }
#endregion #endregion
#endregion #endregion
#region Static #region Static
@ -474,29 +474,29 @@ namespace OpenTK.Math
#endregion #endregion
#region Operators #region Operators
public static Quaternion operator +(Quaternion left, Quaternion right) public static Quaternion operator +(Quaternion left, Quaternion right)
{ {
left.Xyz += right.Xyz; left.Xyz += right.Xyz;
left.W += right.W; left.W += right.W;
return left; return left;
} }
public static Quaternion operator -(Quaternion left, Quaternion right) public static Quaternion operator -(Quaternion left, Quaternion right)
{ {
left.Xyz -= right.Xyz; left.Xyz -= right.Xyz;
left.W -= right.W; left.W -= right.W;
return left; return left;
} }
public static Quaternion operator *(Quaternion left, Quaternion right) public static Quaternion operator *(Quaternion left, Quaternion right)
{ {
float w = left.W * right.W - Vector3.Dot(left.Xyz, right.Xyz); 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.Xyz = right.W * left.Xyz + left.W * right.Xyz + Vector3.Cross(left.Xyz, right.Xyz);
left.W = w; left.W = w;
return left; return left;
} }
public static bool operator ==(Quaternion left, Quaternion right) public static bool operator ==(Quaternion left, Quaternion right)
{ {

View file

@ -45,25 +45,25 @@ namespace OpenTK.Math
#region Constructors #region Constructors
/// <summary> /// <summary>
/// Construct a new Quaterniond from vector and w components /// Construct a new Quaterniond from vector and w components
/// </summary> /// </summary>
/// <param name="v">The vector part</param> /// <param name="v">The vector part</param>
/// <param name="w">The w part</param> /// <param name="w">The w part</param>
public Quaterniond(Vector3d v, double w) public Quaterniond(Vector3d v, double w)
{ {
this.xyz = v; this.xyz = v;
this.w = w; this.w = w;
} }
/// <summary> /// <summary>
/// Construct a new Quaterniond /// Construct a new Quaterniond
/// </summary> /// </summary>
/// <param name="x">The x component</param> /// <param name="x">The x component</param>
/// <param name="y">The y component</param> /// <param name="y">The y component</param>
/// <param name="z">The z component</param> /// <param name="z">The z component</param>
/// <param name="w">The w component</param> /// <param name="w">The w component</param>
public Quaterniond(double x, double y, double z, double w) public Quaterniond(double x, double y, double z, double w)
: this(new Vector3d(x, y, z), w) : this(new Vector3d(x, y, z), w)
{ } { }
@ -156,34 +156,34 @@ namespace OpenTK.Math
return result; return result;
} }
#endregion #endregion
#region public double Length #region public double Length
/// <summary> /// <summary>
/// Gets the length (magnitude) of the Quaterniond. /// Gets the length (magnitude) of the Quaterniond.
/// </summary> /// </summary>
/// <seealso cref="LengthSquared"/> /// <seealso cref="LengthSquared"/>
public double Length public double Length
{ {
get get
{ {
return (double)System.Math.Sqrt(W * W + XYZ.LengthSquared); return (double)System.Math.Sqrt(W * W + Xyz.LengthSquared);
} }
} }
#endregion #endregion
#region public double LengthSquared #region public double LengthSquared
/// <summary> /// <summary>
/// Gets the square of the Quaterniond length (magnitude). /// Gets the square of the Quaterniond length (magnitude).
/// </summary> /// </summary>
public double LengthSquared public double LengthSquared
{ {
get get
{ {
return W * W + XYZ.LengthSquared; return W * W + Xyz.LengthSquared;
} }
} }
@ -203,19 +203,19 @@ namespace OpenTK.Math
#endregion #endregion
#region public void Conjugate() #region public void Conjugate()
/// <summary> /// <summary>
/// Convert this Quaterniond to its conjugate /// Convert this Quaterniond to its conjugate
/// </summary> /// </summary>
public void Conjugate() public void Conjugate()
{ {
Xyz = -Xyz; Xyz = -Xyz;
} }
#endregion #endregion
#endregion #endregion
#region Static #region Static
@ -474,29 +474,29 @@ namespace OpenTK.Math
#endregion #endregion
#region Operators #region Operators
public static Quaterniond operator +(Quaterniond left, Quaterniond right) public static Quaterniond operator +(Quaterniond left, Quaterniond right)
{ {
left.Xyz += right.Xyz; left.Xyz += right.Xyz;
left.W += right.W; left.W += right.W;
return left; return left;
} }
public static Quaterniond operator -(Quaterniond left, Quaterniond right) public static Quaterniond operator -(Quaterniond left, Quaterniond right)
{ {
left.Xyz -= right.Xyz; left.Xyz -= right.Xyz;
left.W -= right.W; left.W -= right.W;
return left; return left;
} }
public static Quaterniond operator *(Quaterniond left, Quaterniond right) public static Quaterniond operator *(Quaterniond left, Quaterniond right)
{ {
double w = left.W * right.W - Vector3d.Dot(left.Xyz, right.Xyz); 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.Xyz = right.W * left.Xyz + left.W * right.Xyz + Vector3d.Cross(left.Xyz, right.Xyz);
left.W = w; left.W = w;
return left; return left;
} }
public static bool operator ==(Quaterniond left, Quaterniond right) public static bool operator ==(Quaterniond left, Quaterniond right)
{ {
@ -619,14 +619,14 @@ namespace OpenTK.Math
/// <summary>Constructs left Quaterniond from the given array of double-precision floating point numbers.</summary> /// <summary>Constructs left Quaterniond from the given array of double-precision floating point numbers.</summary>
/// <param name="doubleArray">The array of doubles for the components of the Quaterniond.</param> /// <param name="doubleArray">The array of doubles for the components of the Quaterniond.</param>
public Quaterniond(double[] doubleArray) public Quaterniond(double[] doubleArray)
{ {
if (doubleArray == null || doubleArray.GetLength(0) < 4) throw new MissingFieldException(); if (doubleArray == null || doubleArray.GetLength(0) < 4) throw new MissingFieldException();
this.W = doubleArray[0]; this.W = doubleArray[0];
this.X = doubleArray[1]; this.X = doubleArray[1];
this.Y = doubleArray[2]; this.Y = doubleArray[2];
this.Z = doubleArray[3]; this.Z = doubleArray[3];
} }
/// <summary>Constructs left Quaterniond from the given matrix. Only contains rotation information.</summary> /// <summary>Constructs left Quaterniond from the given matrix. Only contains rotation information.</summary>
/// <param name="matrix">The matrix for the components of the Quaterniond.</param> /// <param name="matrix">The matrix for the components of the Quaterniond.</param>
@ -795,10 +795,10 @@ namespace OpenTK.Math
} }
} }
public static double DotProduct(Quaterniond left, Quaterniond right) public static double DotProduct(Quaterniond left, Quaterniond right)
{ {
return left.W * right.W + left.X * right.X + left.Y * right.Y + left.Z * right.Z; return left.W * right.W + left.X * right.X + left.Y * right.Y + left.Z * right.Z;
} }
public void Normalize() public void Normalize()
{ {
@ -1045,7 +1045,7 @@ namespace OpenTK.Math
} }
public static void Slerp(ref Quaterniond start, ref Quaterniond end, double blend, out Quaterniond result) public static void Slerp(ref Quaterniond start, ref Quaterniond end, double blend, out Quaterniond result)
{ {
if (start.W == 0 && start.X == 0 && start.Y == 0 && start.Z == 0) if (start.W == 0 && start.X == 0 && start.Y == 0 && start.Z == 0)
{ {
if (end.W == 0 && end.X == 0 && end.Y == 0 && end.Z == 0) if (end.W == 0 && end.X == 0 && end.Y == 0 && end.Z == 0)
@ -1069,37 +1069,37 @@ namespace OpenTK.Math
Vector3d endVector = new Vector3d(end.X, end.Y, end.Z); Vector3d endVector = new Vector3d(end.X, end.Y, end.Z);
double cosHalfAngle = start.W * end.W + Vector3d.Dot(startVector, endVector); double cosHalfAngle = start.W * end.W + Vector3d.Dot(startVector, endVector);
if (cosHalfAngle >= 1.0f || cosHalfAngle <= -1.0f) if (cosHalfAngle >= 1.0f || cosHalfAngle <= -1.0f)
{ {
// angle = 0.0f, so just return one input. // angle = 0.0f, so just return one input.
result = start; result = start;
} }
else if (cosHalfAngle < 0.0f) else if (cosHalfAngle < 0.0f)
{ {
end.W = -end.W; end.W = -end.W;
end.X = -end.X; end.X = -end.X;
end.Y = -end.Y; end.Y = -end.Y;
end.Z = -end.Z; end.Z = -end.Z;
cosHalfAngle = -cosHalfAngle; cosHalfAngle = -cosHalfAngle;
} }
double blendA; double blendA;
double blendB; double blendB;
if (cosHalfAngle < 0.99f) if (cosHalfAngle < 0.99f)
{ {
// do proper slerp for big angles // do proper slerp for big angles
double halfAngle = (double)System.Math.Acos(cosHalfAngle); double halfAngle = (double)System.Math.Acos(cosHalfAngle);
double sinHalfAngle = (double)System.Math.Sin(halfAngle); double sinHalfAngle = (double)System.Math.Sin(halfAngle);
double oneOverSinHalfAngle = 1.0f / sinHalfAngle; double oneOverSinHalfAngle = 1.0f / sinHalfAngle;
blendA = (double)System.Math.Sin(halfAngle * (1.0f - blend)) * oneOverSinHalfAngle; blendA = (double)System.Math.Sin(halfAngle * (1.0f - blend)) * oneOverSinHalfAngle;
blendB = (double)System.Math.Sin(halfAngle * blend) * oneOverSinHalfAngle; blendB = (double)System.Math.Sin(halfAngle * blend) * oneOverSinHalfAngle;
} }
else else
{ {
// do lerp if angle is really small. // do lerp if angle is really small.
blendA = 1.0f - blend; blendA = 1.0f - blend;
blendB = blend; blendB = blend;
} }
result.W = blendA * start.W + blendB * end.W; result.W = blendA * start.W + blendB * end.W;
result.X = blendA * start.X + blendB * end.X; result.X = blendA * start.X + blendB * end.X;
@ -1117,7 +1117,7 @@ namespace OpenTK.Math
result.Y = 0; result.Y = 0;
result.Z = 0; result.Z = 0;
} }
} }
#endregion #endregion