/// <summary> /// Computes a quaternion's axis and angle of rotation. /// </summary> /// <param name="q">Source TGCQuaternion structure. See Remarks.</param> /// <param name="axis">A TGCVector3 structure that identifies the quaternion's axis of rotation.</param> /// <param name="angle">A float value that identifies the quaternion's angle of rotation, in radians.</param> public static void ToAxisAngle(TGCQuaternion q, ref TGCVector3 axis, ref float angle) { //TODO no deberia depender de Vector3 Vector3 tempAxis = axis; Quaternion.ToAxisAngle(q.ToQuaternion(), ref tempAxis, ref angle); axis = new TGCVector3(tempAxis); }
/// <summary> /// Sets up control points for spherical quadrangle interpolation. /// </summary> /// <param name="outA">A TGCQuaternion instance that represents the outA value.</param> /// <param name="outB">A TGCQuaternion instance that represents the outB value.</param> /// <param name="outC">A TGCQuaternion instance that represents the outC value.</param> /// <param name="q0">A TGCQuaternion instance that represents the q0 input control point.</param> /// <param name="q1">A TGCQuaternion instance that represents the q1 input control point.</param> /// <param name="q2">A TGCQuaternion instance that represents the q2 input control point.</param> /// <param name="q3">A TGCQuaternion instance that represents the q3 input control point.</param> public static void SquadSetup(ref TGCQuaternion outA, ref TGCQuaternion outB, ref TGCQuaternion outC, TGCQuaternion q0, TGCQuaternion q1, TGCQuaternion q2, TGCQuaternion q3) { Quaternion tempA = outA; Quaternion tempB = outB; Quaternion tempC = outC; Quaternion.SquadSetup(ref tempA, ref tempA, ref tempA, q0, q1, q2, q3); outA = new TGCQuaternion(tempA); outB = new TGCQuaternion(tempB); outC = new TGCQuaternion(tempC); }
/// <summary> /// Conjugates and re-normalizes a quaternion. /// </summary> /// <param name="q">Source Quaternion.</param> /// <returns>A Quaternion that is the inverse of the quaternion passed into the q parameter.</returns> public static TGCQuaternion Invert(TGCQuaternion q) { return(new TGCQuaternion(Quaternion.Invert(q.ToQuaternion()))); }
/// <summary> /// Interpolates between two quaternions, using spherical linear interpolation. /// </summary> /// <param name="q1">Source TGCQuaternion structure.</param> /// <param name="q2">Source TGCQuaternion structure.</param> /// <param name="t">A float value that indicates how far to interpolate between the quaternions.</param> /// <returns>A TGCQuaternion structure that is the result of the interpolation.</returns> public static TGCQuaternion Slerp(TGCQuaternion q1, TGCQuaternion q2, float t) { return(new TGCQuaternion(Quaternion.Slerp(q1.ToQuaternion(), q2.ToQuaternion(), t))); }
/// <summary> /// Interpolates between quaternions, using spherical quadrangle interpolation. /// </summary> /// <param name="q1">Source TGCQuaternion structure.</param> /// <param name="a">Source TGCQuaternion structure.</param> /// <param name="b">Source TGCQuaternion structure.</param> /// <param name="c">Source TGCQuaternion structure.</param> /// <param name="t">A float value that indicates how far to interpolate between the quaternions.</param> /// <returns></returns> public static TGCQuaternion Squad(TGCQuaternion q1, TGCQuaternion a, TGCQuaternion b, TGCQuaternion c, float t) { return(new TGCQuaternion(Quaternion.Squad(q1.ToQuaternion(), a.ToQuaternion(), b.ToQuaternion(), c.ToQuaternion(), t))); }
/// <summary> /// Multiplies two quaternions. /// </summary> /// <param name="m1">Source Quaternion.</param> /// <param name="m2">Source Quaternion.</param> /// <returns>A Quaternion that is the product of two quaternions.</returns> public static TGCQuaternion Multiply(TGCQuaternion m1, TGCQuaternion m2) { return(new TGCQuaternion(Quaternion.Multiply(m1.ToQuaternion(), m2.ToQuaternion()))); }
/// <summary> /// Returns the normal of a quaternion. /// </summary> /// <param name="q">Source Quaternion.</param> /// <returns>A Quaternion that is the normal of the quaternion.</returns> public static TGCQuaternion Normalize(TGCQuaternion q) { return(new TGCQuaternion(Quaternion.Normalize(q.ToQuaternion()))); }
/// <summary> /// Rotates a matrix from a quaternion. /// </summary> /// <param name="quat">Source TGCQuaternion structure that defines the rotation.</param> public void RotateTGCQuaternion(TGCQuaternion quat) { this.dxMatrix.RotateQuaternion(quat); }
/// <summary> /// Multiplies two quaternions. /// </summary> /// <param name="q">Source Quaternion.</param> public void Multiply(TGCQuaternion q) { this.dxQuaternion.Multiply(q.ToQuaternion()); }
/// <summary> /// Subtracts two quaternion instances. /// </summary> /// <param name="m1">Source Quaternion structure to the left of the subtraction operator.</param> /// <param name="m2">Source Quaternion structure to the right of the subtraction operator.</param> /// <returns>A Quaternion structure that is the result of the operation.</returns> public static TGCQuaternion Subtract(TGCQuaternion m1, TGCQuaternion m2) { return(new TGCQuaternion(Quaternion.Subtract(m1.ToQuaternion(), m1.ToQuaternion()))); }
/// <summary> /// Convierte un TGCQuaternion a un float[4] /// </summary> public static float[] TGCQuaternionToFloat4Array(TGCQuaternion q) { return(new[] { q.X, q.Y, q.Z, q.W }); }
/// <summary> /// Returns the dot product of two quaternions. /// </summary> /// <param name="v1">Source Quaternion.</param> /// <param name="v2">Source Quaternion.</param> /// <returns>Dot product of two quaternions.</returns> public static float Dot(TGCQuaternion v1, TGCQuaternion v2) { return(Quaternion.Dot(v1.ToQuaternion(), v2.ToQuaternion())); }
/// <summary> /// Calculates the exponential. /// </summary> /// <param name="q">Source Quaternion.</param> /// <returns>The Quaternion that is the exponential of the q parameter.</returns> public static TGCQuaternion Exp(TGCQuaternion q) { return(new TGCQuaternion(Quaternion.Exp(q.ToQuaternion()))); }
/// <summary> /// Returns the conjugate of a quaternion. /// </summary> /// <param name="q">Returns the conjugate of a quaternion.</param> /// <returns>A Quaternion that is the conjugate of the q parameter.</returns> public static TGCQuaternion Conjugate(TGCQuaternion q) { return(new TGCQuaternion(Quaternion.Conjugate(q.ToQuaternion()))); }
/// <summary> /// Returns a quaternion in barycentric coordinates. /// </summary> /// <param name="q1">Source Quaternion.</param> /// <param name="q2">Source Quaternion.</param> /// <param name="q3">Source Quaternion.</param> /// <param name="f">Weighting factor.</param> /// <param name="g">Weighting factor.</param> /// <returns>Resulting Quaternion in barycentric coordinates.</returns> public static TGCQuaternion BaryCentric(TGCQuaternion q1, TGCQuaternion q2, TGCQuaternion q3, float f, float g) { return(new TGCQuaternion(Quaternion.BaryCentric(q1.ToQuaternion(), q2.ToQuaternion(), q3.ToQuaternion(), f, g))); }
/// <summary> /// Builds a transformation matrix. /// </summary> /// <param name="scalingCenter">A TGCVector3 that identifies the scaling center point.</param> /// <param name="scalingRotation">A TGCQuaternion structure that specifies the scaling rotation. Use TGCQuaternion.Identity to specify no scaling.</param> /// <param name="scalingFactor">A TGCVector3 that is the scaling vector.</param> /// <param name="rotationCenter">A TGCVector3 that is a point that identifies the center of rotation.</param> /// <param name="rotation">A TGCQuaternion structure that specifies the rotation. Use TGCQuaternion.Identity to specify no rotation.</param> /// <param name="translation">A TGCVector3 that represents the translation. Use Vector3.Empty to specify no translation.</param> /// <returns>Resulting TGCMatrix.</returns> public static TGCMatrix Transformation(TGCVector3 scalingCenter, TGCQuaternion scalingRotation, TGCVector3 scalingFactor, TGCVector3 rotationCenter, TGCQuaternion rotation, TGCVector3 translation) { return(new TGCMatrix(Matrix.Transformation(scalingCenter, scalingRotation, scalingFactor, rotationCenter, rotation, translation))); }
/// <summary> /// Transforms the matrix. /// </summary> /// <param name="scalingCenter">A TGCVector3 that identifies the scaling center point.</param> /// <param name="scalingRotation">A TGCQuaternion structure that specifies the scaling rotation. Use TGCQuaternion.Identity to specify no scaling.</param> /// <param name="scalingFactor">A TGCVector3 that is the scaling vector.</param> /// <param name="rotationCenter">A TGCVector3 that is a point that identifies the center of rotation.</param> /// <param name="rotation">A TGCQuaternion structure that specifies the rotation. Use TGCQuaternion.Identity to specify no rotation.</param> /// <param name="translation">A TGCVector3 that represents the translation. Use Vector3.Empty to specify no translation.</param> public void Transform(TGCVector3 scalingCenter, TGCQuaternion scalingRotation, TGCVector3 scalingFactor, TGCVector3 rotationCenter, TGCQuaternion rotation, TGCVector3 translation) { this.dxMatrix.Transform(scalingCenter, scalingRotation, scalingFactor, rotationCenter, rotation, translation); }
/// <summary> /// Builds a matrix from a quaternion. /// </summary> /// <param name="quat">Source TGCQuaternion structure.</param> /// <returns>Rotated TGCMatrix.</returns> public static TGCMatrix RotationTGCQuaternion(TGCQuaternion quat) { return(new TGCMatrix(Matrix.RotationQuaternion(quat))); }
/// <summary> /// Returns the square of a quaternion's length. /// </summary> /// <param name="v">Source Quaternion.</param> /// <returns>A float that represents the quaternion's squared length.</returns> public static float LengthSq(TGCQuaternion v) { return(Quaternion.LengthSq(v.ToQuaternion())); }
/// <summary> /// Calculates the natural logarithm. /// </summary> /// <param name="q">Source Quaternion.</param> /// <returns>A Quaternion that is the natural logarithm of the quaternion passed into the q parameter.</returns> public static TGCQuaternion Ln(TGCQuaternion q) { return(new TGCQuaternion(Quaternion.Ln(q.ToQuaternion()))); }
/// <summary> /// Adds two quaternions. /// </summary> /// <param name="m1">Source Quaternion.</param> /// <param name="m2">Source Quaternion.</param> /// <returns>Sum of the two source Quaternion.</returns> public static TGCQuaternion Add(TGCQuaternion m1, TGCQuaternion m2) { return(new TGCQuaternion(Quaternion.Add(m1.ToQuaternion(), m2.ToQuaternion()))); }
/// <summary> /// Builds a 3-D affine transformation matrix. /// </summary> /// <param name="scaling">Scaling factor. A value of zero indicates no scaling.</param> /// <param name="rotationCenter">A TGCVector3 that indicates the point at the center of rotation.</param> /// <param name="rotation">A /// structure that specifies the rotation. Use TGCQuaternion.Identity to specify no rotation.</param> /// <param name="translation">A TGCVector3 that represents the translation. Use TGCVector3.Empty to specify no translation.</param> public void AffineTransformation(float scaling, TGCVector3 rotationCenter, TGCQuaternion rotation, TGCVector3 translation) { this.dxMatrix.AffineTransformation(scaling, rotationCenter, rotation, translation); }