예제 #1
0
        public static Vector3f Transform(Vector3f vector, Quaternionf rotation)
        {
            var v = rotation * new Quaternionf(vector.X, vector.Y, vector.Z, 0) * Conjugate(rotation);

            return(new Vector3f(v.A, v.B, v.C));
        }
예제 #2
0
 /// <summary>
 /// Computes the argument of a quaternion and returns the result.
 /// </summary>
 /// <param name="value">A quaternion.</param>
 /// <returns>The argument of value.</returns>
 public static float Argument(Quaternionf value)
 {
     return(Functions.Atan2(Absolute(Imaginary(value)), value.A));
 }
예제 #3
0
 /// <summary>
 /// Calculates the dot product (inner product) of two quaternions.
 /// </summary>
 /// <param name="left">First source quaternion.</param>
 /// <param name="right">Second source quaternion.</param>
 /// <returns>The dot product of the two quaternions.</returns>
 public static float Dot(Quaternionf left, Quaternionf right)
 {
     return(left.A * right.A + left.B * right.B + left.C * right.C + left.D * right.D);
 }
예제 #4
0
 /// <summary>
 /// Computes the absolute value (or modulus or magnitude) of a quaternion and returns the result.
 /// </summary>
 /// <param name="value">A quaternion.</param>
 /// <returns>The absolute value of value.</returns>
 public static float Absolute(Quaternionf value)
 {
     return(Functions.Sqrt(value.A * value.A + value.B * value.B + value.C * value.C + value.D * value.D));
 }
예제 #5
0
 /// <summary>
 /// Computes the conjugate of a quaternion and returns the result.
 /// </summary>
 /// <param name="value">A quaternion.</param>
 /// <returns>The conjugate of value.</returns>
 public static Quaternionf Conjugate(Quaternionf value)
 {
     return(new Quaternionf(value.A, -value.B, -value.C, -value.D));
 }
예제 #6
0
 /// <summary>
 /// Return imaginary part of a quaternion.
 /// </summary>
 /// <param name="value">A quaternion.</param>
 /// <returns>The imaginary part of a quaternion.</returns>
 public static Quaternionf Imaginary(Quaternionf value)
 {
     return(new Quaternionf(0, value.B, value.C, value.D));
 }
예제 #7
0
 /// <summary>
 /// Computes the absolute squared value of a quaternion and returns the result.
 /// </summary>
 /// <param name="value">A quaternion.</param>
 /// <returns>The absolute squared value of value.</returns>
 public static float AbsoluteSquared(Quaternionf value)
 {
     return(value.A * value.A + value.B * value.B + value.C * value.C + value.D * value.D);
 }
예제 #8
0
 /// <summary>
 /// Determines whether any components of a quaternion satisfy a condition.
 /// </summary>
 /// <param name="value">A quaternion.</param>
 /// <param name="predicate">A function to test each component for a condition.</param>
 /// <returns>true if any component of the quaternion passes the test in the specified
 /// predicate; otherwise, false.</returns>
 public static bool Any(Quaternionf value, Predicate <float> predicate)
 {
     return(predicate(value.A) || predicate(value.B) || predicate(value.C) || predicate(value.D));
 }
예제 #9
0
 /// <summary>
 /// Return real part of a quaternion.
 /// </summary>
 /// <param name="value">A quaternion.</param>
 /// <returns>The real part of a quaternion.</returns>
 public static Quaternionf Real(Quaternionf value)
 {
     return(new Quaternionf(value.A, 0, 0, 0));
 }
예제 #10
0
 /// <summary>
 /// Determines whether all components of a quaternion satisfy a condition.
 /// </summary>
 /// <param name="value">A quaternion.</param>
 /// <param name="predicate">A function to test each component for a condition.</param>
 /// <returns>true if every component of the quaternion passes the test in the specified
 /// predicate; otherwise, false.</returns>
 public static bool All(Quaternionf value, Predicate <float> predicate)
 {
     return(predicate(value.A) && predicate(value.B) && predicate(value.C) && predicate(value.D));
 }
예제 #11
0
 /// <summary>
 /// Determines whether any component of a quaternion is non-zero.
 /// </summary>
 /// <param name="value">A quaternion.</param>
 /// <returns>true if any components are non-zero; false otherwise.</returns>
 public static bool Any(Quaternionf value)
 {
     return(value.A != 0 || value.B != 0 || value.C != 0 || value.D != 0);
 }
예제 #12
0
 /// <summary>
 /// Determines whether all components of a quaternion are non-zero.
 /// </summary>
 /// <param name="value">A quaternion.</param>
 /// <returns>true if all components are non-zero; false otherwise.</returns>
 public static bool All(Quaternionf value)
 {
     return(value.A != 0 && value.B != 0 && value.C != 0 && value.D != 0);
 }
예제 #13
0
 /// <summary>
 /// Returns a value that indicates whether two quaternions are equal.
 /// </summary>
 /// <param name="left">The first quaternion to compare.</param>
 /// <param name="right">The second quaternion to compare.</param>
 /// <returns>true if the left and right are equal; otherwise, false.</returns>
 public static bool Equals(Quaternionf left, Quaternionf right)
 {
     return(left == right);
 }
예제 #14
0
 /// <summary>
 /// Subtracts one quaternion from another and returns the result.
 /// </summary>
 /// <param name="left">The value to subtract from (the minuend).</param>
 /// <param name="right">The value to subtract (the subtrahend).</param>
 /// <returns>The result of subtracting right from left (the difference).</returns>
 public static Quaternionf Subtract(Quaternionf left, Quaternionf right)
 {
     return(new Quaternionf(left.A - right.A, left.B - right.B, left.C - right.C, left.D - right.D));
 }
예제 #15
0
 /// <summary>
 /// Adds two quaternions and returns the result.
 /// </summary>
 /// <param name="left">The first value to add.</param>
 /// <param name="right">The second value to add.</param>
 /// <returns>The sum of left and right.</returns>
 public static Quaternionf Add(Quaternionf left, Quaternionf right)
 {
     return(new Quaternionf(left.A + right.A, left.B + right.B, left.C + right.C, left.D + right.D));
 }
예제 #16
0
 /// <summary>
 /// Returns the additive inverse of a quaternion.
 /// </summary>
 /// <param name="value">A quaternion.</param>
 /// <returns>The negative of value.</returns>
 public static Quaternionf Negative(Quaternionf value)
 {
     return(new Quaternionf(-value.A, -value.B, -value.C, -value.D));
 }