Exemplo n.º 1
0
        /// <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);
        }
Exemplo n.º 2
0
        /// <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);
        }
Exemplo n.º 3
0
 /// <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())));
 }
Exemplo n.º 4
0
 /// <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)));
 }
Exemplo n.º 5
0
 /// <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)));
 }
Exemplo n.º 6
0
 /// <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())));
 }
Exemplo n.º 7
0
 /// <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())));
 }
Exemplo n.º 8
0
 /// <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);
 }
Exemplo n.º 9
0
 /// <summary>
 /// Multiplies two quaternions.
 /// </summary>
 /// <param name="q">Source Quaternion.</param>
 public void Multiply(TGCQuaternion q)
 {
     this.dxQuaternion.Multiply(q.ToQuaternion());
 }
Exemplo n.º 10
0
 /// <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())));
 }
Exemplo n.º 11
0
 /// <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 });
 }
Exemplo n.º 12
0
 /// <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()));
 }
Exemplo n.º 13
0
 /// <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())));
 }
Exemplo n.º 14
0
 /// <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())));
 }
Exemplo n.º 15
0
 /// <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)));
 }
Exemplo n.º 16
0
 /// <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)));
 }
Exemplo n.º 17
0
 /// <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);
 }
Exemplo n.º 18
0
 /// <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)));
 }
Exemplo n.º 19
0
 /// <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()));
 }
Exemplo n.º 20
0
 /// <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())));
 }
Exemplo n.º 21
0
 /// <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())));
 }
Exemplo n.º 22
0
 /// <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);
 }