Microsoft.Xna.Framework
Class Quaternion

java.lang.Object
  extended by System.ValueType
      extended by Microsoft.Xna.Framework.Quaternion
All Implemented Interfaces:
IEquatable<Quaternion>

public final class Quaternion
extends ValueType
implements IEquatable<Quaternion>

Defines a four-dimensional vector (x,y,z,w), which is used to efficiently rotate an object about the (x, y, z) vector by the angle theta, where w = cos(theta/2).

Author:
Halofreak1990

Field Summary
 Quaternion Identity
          Returns a Quaternion representing no rotation.
 float W
          Specifies the rotation component of the quaternion.
 float X
          Specifies the x-value of the vector component of the quaternion.
 float Y
          Specifies the y-value of the vector component of the quaternion.
 float Z
          Specifies the z-value of the vector component of the quaternion.
 
Constructor Summary
Quaternion()
          Initializes a new instance of Quaternion.
Quaternion(float x, float y, float z, float w)
          Initializes a new instance of Quaternion.
Quaternion(Vector3 vectorPart, float scalarPart)
          Initializes a new instance of Quaternion.
 
Method Summary
 void Add(Quaternion other)
          Adds the specified quaternion to the current quaternion.
static Quaternion Add(Quaternion quaternion1, Quaternion quaternion2)
          Adds two Quaternions.
static void Add(Quaternion quaternion1, Quaternion quaternion2, Quaternion result)
          Adds two Quaternions.
static Quaternion Concatenate(Quaternion value1, Quaternion value2)
          Concatenates two Quaternions; the result represents the value1 rotation followed by the value2 rotation.
static void Concatenate(Quaternion value1, Quaternion value2, Quaternion result)
          Concatenates two Quaternions; the result represents the value1 rotation followed by the value2 rotation.
 void Conjugate()
          Transforms this Quaternion into its conjugate.
static Quaternion Conjugate(Quaternion value)
          Returns the conjugate of a specified Quaternion.
static void Conjugate(Quaternion value, Quaternion result)
          Returns the conjugate of a specified Quaternion.
static Quaternion CreateFromAxisAngle(Vector3 axis, float angle)
          Creates a Quaternion from a vector and an angle to rotate about the vector.
static void CreateFromAxisAngle(Vector3 axis, float angle, Quaternion result)
          Creates a Quaternion from a vector and an angle to rotate about the vector.
static Quaternion CreateFromRotationMatrix(Matrix matrix)
          Creates a Quaternion from a rotation Matrix.
static void CreateFromRotationMatrix(Matrix matrix, Quaternion result)
          Creates a Quaternion from a rotation Matrix.
static Quaternion CreateFromYawPitchRoll(float yaw, float pitch, float roll)
          Creates a new Quaternion from specified yaw, pitch, and roll angles.
static void CreateFromYawPitchRoll(float yaw, float pitch, float roll, Quaternion result)
          Creates a new Quaternion from specified yaw, pitch, and roll angles.
 void Divide(Quaternion other)
          Divides the current quaternion by the specified quaternion.
static Quaternion Divide(Quaternion quaternion1, Quaternion quaternion2)
          Divides a Quaternion by another Quaternion.
static void Divide(Quaternion quaternion1, Quaternion quaternion2, Quaternion result)
          Divides a Quaternion by another Quaternion.
static float Dot(Quaternion quaternion1, Quaternion quaternion2)
          Calculates the dot product of two Quaternions.
static void Dot(Quaternion quaternion1, Quaternion quaternion2, float result)
          Calculates the dot product of two Quaternions.
 boolean equals(java.lang.Object obj)
          Returns a value that indicates whether the current instance is equal to a specified object.
 boolean Equals(Quaternion other)
          Determines whether the specified Object is equal to the Quaternion.
 int hashCode()
          Get the hash code of this object.
static Quaternion Inverse(Quaternion quaternion)
          Returns the inverse of a Quaternion.
static void Inverse(Quaternion quaternion, Quaternion result)
          Returns the inverse of a Quaternion.
 float Length()
          Calculates the length of a Quaternion.
 float LengthSquared()
          Calculates the length squared of a Quaternion.
static Quaternion Lerp(Quaternion quaternion1, Quaternion quaternion2, float amount)
          Linearly interpolates between two quaternions.
static void Lerp(Quaternion quaternion1, Quaternion quaternion2, float amount, Quaternion result)
          Linearly interpolates between two quaternions.
 void Multiply(float scaleFactor)
          Multiplies the current quaternion by the specified scalar value.
 void Multiply(Quaternion other)
          Multiplies the current quaternion by the specified quaternion.
static Quaternion Multiply(Quaternion quaternion1, float scaleFactor)
          Multiplies a quaternion by a scalar value.
static void Multiply(Quaternion quaternion1, float scaleFactor, Quaternion result)
          Multiplies a quaternion by a scalar value.
static Quaternion Multiply(Quaternion quaternion1, Quaternion quaternion2)
          Multiplies two quaternions.
static void Multiply(Quaternion quaternion1, Quaternion quaternion2, Quaternion result)
          Multiplies two quaternions.
static Quaternion Negate(Quaternion quaternion)
          Flips the sign of each component of the quaternion.
static void Negate(Quaternion quaternion, Quaternion result)
          Flips the sign of each component of the quaternion.
 void Normalize()
          Divides each component of the quaternion by the length of the quaternion.
static Quaternion Normalize(Quaternion quaternion)
          Divides each component of the quaternion by the length of the quaternion.
static void Normalize(Quaternion quaternion, Quaternion result)
          Divides each component of the quaternion by the length of the quaternion.
static Quaternion Slerp(Quaternion quaternion1, Quaternion quaternion2, float amount)
          Interpolates between two quaternions, using spherical linear interpolation.
static void Slerp(Quaternion quaternion1, Quaternion quaternion2, float amount, Quaternion result)
          Interpolates between two quaternions, using spherical linear interpolation.
 void Subtract(Quaternion other)
          Subtracts the specified Quaternion from the current quaternion.
static Quaternion Subtract(Quaternion quaternion1, Quaternion quaternion2)
          Subtracts a quaternion from another quaternion.
static void Subtract(Quaternion quaternion1, Quaternion quaternion2, Quaternion result)
          Subtracts a quaternion from another quaternion.
 java.lang.String ToString()
           
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

Identity

public final Quaternion Identity
Returns a Quaternion representing no rotation.


X

public float X
Specifies the x-value of the vector component of the quaternion.


Y

public float Y
Specifies the y-value of the vector component of the quaternion.


Z

public float Z
Specifies the z-value of the vector component of the quaternion.


W

public float W
Specifies the rotation component of the quaternion.

Constructor Detail

Quaternion

public Quaternion(Vector3 vectorPart,
                  float scalarPart)
Initializes a new instance of Quaternion.

Parameters:
vectorPart - The vector component of the quaternion.
scalarPart - The rotation component of the quaternion.

Quaternion

public Quaternion(float x,
                  float y,
                  float z,
                  float w)
Initializes a new instance of Quaternion.

Parameters:
x - The x-value of the quaternion.
y - The y-value of the quaternion.
z - The z-value of the quaternion.
w - The w-value of the quaternion.

Quaternion

public Quaternion()
Initializes a new instance of Quaternion.

Method Detail

Add

public void Add(Quaternion other)
Adds the specified quaternion to the current quaternion.

Parameters:
other - Source quaternion.

Add

public static Quaternion Add(Quaternion quaternion1,
                             Quaternion quaternion2)
Adds two Quaternions.

Parameters:
quaternion1 - Quaternion to add.
quaternion2 - Quaternion to add.

Add

public static void Add(Quaternion quaternion1,
                       Quaternion quaternion2,
                       Quaternion result)
Adds two Quaternions.

Parameters:
quaternion1 - Quaternion to add.
quaternion2 - Quaternion to add.
result - [OutAttribute] Result of adding the Quaternions.

Concatenate

public static Quaternion Concatenate(Quaternion value1,
                                     Quaternion value2)
Concatenates two Quaternions; the result represents the value1 rotation followed by the value2 rotation.

Parameters:
value1 - The first Quaternion rotation in the series.
value2 - The second Quaternion rotation in the series.

Concatenate

public static void Concatenate(Quaternion value1,
                               Quaternion value2,
                               Quaternion result)
Concatenates two Quaternions; the result represents the value1 rotation followed by the value2 rotation.

Parameters:
value1 - The first Quaternion rotation in the series.
value2 - The second Quaternion rotation in the series.
result - [OutAttribute] The Quaternion rotation representing the concatenation of value1 followed by value2.

Conjugate

public void Conjugate()
Transforms this Quaternion into its conjugate.


Conjugate

public static Quaternion Conjugate(Quaternion value)
Returns the conjugate of a specified Quaternion.

Parameters:
value - The Quaternion of which to return the conjugate.

Conjugate

public static void Conjugate(Quaternion value,
                             Quaternion result)
Returns the conjugate of a specified Quaternion.

Parameters:
value - The Quaternion of which to return the conjugate.
result - [OutAttribute] An existing Quaternion filled in to be the conjugate of the specified one.

CreateFromAxisAngle

public static Quaternion CreateFromAxisAngle(Vector3 axis,
                                             float angle)
Creates a Quaternion from a vector and an angle to rotate about the vector.

Parameters:
axis - The vector to rotate around.
angle - The angle to rotate around the vector.

CreateFromAxisAngle

public static void CreateFromAxisAngle(Vector3 axis,
                                       float angle,
                                       Quaternion result)
Creates a Quaternion from a vector and an angle to rotate about the vector.

Parameters:
axis - The vector to rotate around.
angle - The angle to rotate around the vector.
result - [OutAttribute] The created Quaternion.

CreateFromRotationMatrix

public static Quaternion CreateFromRotationMatrix(Matrix matrix)
Creates a Quaternion from a rotation Matrix.

Parameters:
matrix - The rotation Matrix to create the Quaternion from.

CreateFromRotationMatrix

public static void CreateFromRotationMatrix(Matrix matrix,
                                            Quaternion result)
Creates a Quaternion from a rotation Matrix.

Parameters:
matrix - The rotation Matrix to create the Quaternion from.
result - [OutAttribute] The created Quaternion.

CreateFromYawPitchRoll

public static Quaternion CreateFromYawPitchRoll(float yaw,
                                                float pitch,
                                                float roll)
Creates a new Quaternion from specified yaw, pitch, and roll angles.

Parameters:
yaw - The yaw angle, in radians, around the y-axis.
pitch - The pitch angle, in radians, around the x-axis.
roll - The roll angle, in radians, around the z-axis.

CreateFromYawPitchRoll

public static void CreateFromYawPitchRoll(float yaw,
                                          float pitch,
                                          float roll,
                                          Quaternion result)
Creates a new Quaternion from specified yaw, pitch, and roll angles.

Parameters:
yaw - The yaw angle, in radians, around the y-axis.
pitch - The pitch angle, in radians, around the x-axis.
roll - The roll angle, in radians, around the z-axis.
result - [OutAttribute] An existing Quaternion filled in to express the specified yaw, pitch, and roll angles.

Divide

public void Divide(Quaternion other)
Divides the current quaternion by the specified quaternion.

Parameters:
other - Source quaternion.

Divide

public static Quaternion Divide(Quaternion quaternion1,
                                Quaternion quaternion2)
Divides a Quaternion by another Quaternion.

Parameters:
quaternion1 - Source Quaternion.
quaternion2 - The divisor.

Divide

public static void Divide(Quaternion quaternion1,
                          Quaternion quaternion2,
                          Quaternion result)
Divides a Quaternion by another Quaternion.

Parameters:
quaternion1 - Source Quaternion.
quaternion2 - The divisor.
result - [OutAttribute] Result of the division.

Dot

public static float Dot(Quaternion quaternion1,
                        Quaternion quaternion2)
Calculates the dot product of two Quaternions.

Parameters:
quaternion1 - Source Quaternion.
quaternion2 - Source Quaternion.

Dot

public static void Dot(Quaternion quaternion1,
                       Quaternion quaternion2,
                       float result)
Calculates the dot product of two Quaternions.

Parameters:
quaternion1 - Source Quaternion.
quaternion2 - Source Quaternion.
result - [OutAttribute] Dot product of the Quaternions.

equals

public boolean equals(java.lang.Object obj)
Returns a value that indicates whether the current instance is equal to a specified object.

Overrides:
equals in class java.lang.Object
Parameters:
obj - to make the comparison with.

Equals

public boolean Equals(Quaternion other)
Determines whether the specified Object is equal to the Quaternion.

Specified by:
Equals in interface IEquatable<Quaternion>
Parameters:
other - The Quaternion to compare with the current Quaternion.
Returns:
true if the current object is equal to the other parameter; otherwise, false.

hashCode

public int hashCode()
Get the hash code of this object.

Overrides:
hashCode in class java.lang.Object

Inverse

public static Quaternion Inverse(Quaternion quaternion)
Returns the inverse of a Quaternion.

Parameters:
quaternion - Source Quaternion.

Inverse

public static void Inverse(Quaternion quaternion,
                           Quaternion result)
Returns the inverse of a Quaternion.

Parameters:
quaternion - Source Quaternion.
result - [OutAttribute] The inverse of the Quaternion.

Length

public float Length()
Calculates the length of a Quaternion.


LengthSquared

public float LengthSquared()
Calculates the length squared of a Quaternion.


Lerp

public static Quaternion Lerp(Quaternion quaternion1,
                              Quaternion quaternion2,
                              float amount)
Linearly interpolates between two quaternions.

Parameters:
quaternion1 - Source quaternion.
quaternion2 - Source quaternion.
amount - Value indicating how far to interpolate between the quaternions.

Lerp

public static void Lerp(Quaternion quaternion1,
                        Quaternion quaternion2,
                        float amount,
                        Quaternion result)
Linearly interpolates between two quaternions.

Parameters:
quaternion1 - Source quaternion.
quaternion2 - Source quaternion.
amount - Value indicating how far to interpolate between the quaternions.
result - [OutAttribute] The resulting quaternion.

Multiply

public void Multiply(Quaternion other)
Multiplies the current quaternion by the specified quaternion.

Parameters:
other - Source quaternion.

Multiply

public void Multiply(float scaleFactor)
Multiplies the current quaternion by the specified scalar value.

Parameters:
scaleFactor - Scalar value.

Multiply

public static Quaternion Multiply(Quaternion quaternion1,
                                  Quaternion quaternion2)
Multiplies two quaternions.

Parameters:
quaternion1 - The quaternion on the left of the multiplication.
quaternion2 - The quaternion on the right of the multiplication.

Multiply

public static Quaternion Multiply(Quaternion quaternion1,
                                  float scaleFactor)
Multiplies a quaternion by a scalar value.

Parameters:
quaternion1 - Source quaternion.
scaleFactor - Scalar value.

Multiply

public static void Multiply(Quaternion quaternion1,
                            Quaternion quaternion2,
                            Quaternion result)
Multiplies two quaternions.

Parameters:
quaternion1 - The quaternion on the left of the multiplication.
quaternion2 - The quaternion on the right of the multiplication.
result - [OutAttribute] The result of the multiplication.

Multiply

public static void Multiply(Quaternion quaternion1,
                            float scaleFactor,
                            Quaternion result)
Multiplies a quaternion by a scalar value.

Parameters:
quaternion1 - Source quaternion.
scaleFactor - Scalar value.
result - [OutAttribute] The result of the multiplication.

Negate

public static Quaternion Negate(Quaternion quaternion)
Flips the sign of each component of the quaternion.

Parameters:
quaternion - Source quaternion.

Negate

public static void Negate(Quaternion quaternion,
                          Quaternion result)
Flips the sign of each component of the quaternion.

Parameters:
quaternion - Source quaternion.
result - [OutAttribute] Negated quaternion.

Normalize

public void Normalize()
Divides each component of the quaternion by the length of the quaternion.


Normalize

public static Quaternion Normalize(Quaternion quaternion)
Divides each component of the quaternion by the length of the quaternion.

Parameters:
quaternion - Source quaternion.

Normalize

public static void Normalize(Quaternion quaternion,
                             Quaternion result)
Divides each component of the quaternion by the length of the quaternion.

Parameters:
quaternion - Source quaternion.
result - [OutAttribute] Normalized quaternion.

Slerp

public static Quaternion Slerp(Quaternion quaternion1,
                               Quaternion quaternion2,
                               float amount)
Interpolates between two quaternions, using spherical linear interpolation.

Parameters:
quaternion1 - Source quaternion.
quaternion2 - Source quaternion.
amount - Value that indicates how far to interpolate between the quaternions.

Slerp

public static void Slerp(Quaternion quaternion1,
                         Quaternion quaternion2,
                         float amount,
                         Quaternion result)
Interpolates between two quaternions, using spherical linear interpolation.

Parameters:
quaternion1 - Source quaternion.
quaternion2 - Source quaternion.
amount - Value that indicates how far to interpolate between the quaternions.
result - [OutAttribute] Result of the interpolation.

Subtract

public void Subtract(Quaternion other)
Subtracts the specified Quaternion from the current quaternion.

Parameters:
other - Source Quaternion.

Subtract

public static Quaternion Subtract(Quaternion quaternion1,
                                  Quaternion quaternion2)
Subtracts a quaternion from another quaternion.

Parameters:
quaternion1 - Source quaternion.
quaternion2 - Source quaternion.

Subtract

public static void Subtract(Quaternion quaternion1,
                            Quaternion quaternion2,
                            Quaternion result)
Subtracts a quaternion from another quaternion.

Parameters:
quaternion1 - Source quaternion.
quaternion2 - Source quaternion.
result - [OutAttribute] Result of the subtraction.

ToString

public java.lang.String ToString()