Share via


Quaternion Structure

Microsoft Silverlight will reach end of support after October 2021. Learn more.

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).

Namespace:  Microsoft.Xna.Framework
Assembly:  Microsoft.Xna.Framework.Math (in Microsoft.Xna.Framework.Math.dll)

Syntax

'Declaration
Public Structure Quaternion
public struct Quaternion

The Quaternion type exposes the following members.

Constructors

  Name Description
Public method Quaternion(Vector3, Single) Initializes a new instance of Quaternion.
Public method Quaternion(Single, Single, Single, Single) Initializes a new instance of Quaternion.

Top

Properties

  Name Description
Public propertyStatic member Identity Returns a Quaternion representing no rotation.

Top

Methods

  Name Description
Public methodStatic member Add(Quaternion, Quaternion) Adds two Quaternion instances.
Public methodStatic member Add(Quaternion%, Quaternion%, Quaternion%) Adds two Quaternion instances.
Public methodStatic member Concatenate(Quaternion, Quaternion) Concatenates two Quaternion instances; the result represents the value1 rotation followed by the value2 rotation.
Public methodStatic member Concatenate(Quaternion%, Quaternion%, Quaternion%) Concatenates two Quaternion instances; the result represents the value1 rotation followed by the value2 rotation.
Public method Conjugate() Transforms this Quaternion into its conjugate.
Public methodStatic member Conjugate(Quaternion) Returns the conjugate of a specified Quaternion.
Public methodStatic member Conjugate(Quaternion%, Quaternion%) Returns the conjugate of a specified Quaternion.
Public methodStatic member CreateFromAxisAngle(Vector3, Single) Creates a Quaternion from a vector and an angle to rotate about the vector.
Public methodStatic member CreateFromAxisAngle(Vector3%, Single, Quaternion%) Creates a Quaternion from a vector and an angle to rotate about the vector.
Public methodStatic member CreateFromRotationMatrix(Matrix) Creates a Quaternion from a rotation Matrix.
Public methodStatic member CreateFromRotationMatrix(Matrix%, Quaternion%) Creates a Quaternion from a rotation Matrix.
Public methodStatic member CreateFromYawPitchRoll(Single, Single, Single) Creates a new Quaternion from specified yaw, pitch, and roll angles.
Public methodStatic member CreateFromYawPitchRoll(Single, Single, Single, Quaternion%) Creates a new Quaternion from specified yaw, pitch, and roll angles.
Public methodStatic member Divide(Quaternion, Quaternion) Divides a Quaternion by another Quaternion.
Public methodStatic member Divide(Quaternion%, Quaternion%, Quaternion%) Divides a Quaternion by another Quaternion.
Public methodStatic member Dot(Quaternion, Quaternion) Calculates the dot product of two Quaternion instances.
Public methodStatic member Dot(Quaternion%, Quaternion%, Single%) Calculates the dot product of two Quaternion instances.
Public method Equals(Object) Returns a value that indicates whether the current instance is equal to a specified object. (Overrides ValueType.Equals(Object).)
Public method Equals(Quaternion) Determines whether the specified Object is equal to the Quaternion.
Public method GetHashCode Get the hash code of this object. (Overrides ValueType.GetHashCode().)
Public methodStatic member Inverse(Quaternion) Returns the inverse of a Quaternion.
Public methodStatic member Inverse(Quaternion%, Quaternion%) Returns the inverse of a Quaternion.
Public method Length Calculates the length of a Quaternion.
Public method LengthSquared Calculates the length squared of a Quaternion.
Public methodStatic member Lerp(Quaternion, Quaternion, Single) Linearly interpolates between two Quaternion instances.
Public methodStatic member Lerp(Quaternion%, Quaternion%, Single, Quaternion%) Linearly interpolates between two Quaternion instances.
Public methodStatic member Multiply(Quaternion, Quaternion) Multiplies two Quaternion instances.
Public methodStatic member Multiply(Quaternion, Single) Multiplies a Quaternion by a scalar value.
Public methodStatic member Multiply(Quaternion%, Quaternion%, Quaternion%) Multiplies two Quaternion instances.
Public methodStatic member Multiply(Quaternion%, Single, Quaternion%) Multiplies a Quaternion by a scalar value.
Public methodStatic member Negate(Quaternion) Flips the sign of each component of the Quaternion.
Public methodStatic member Negate(Quaternion%, Quaternion%) Flips the sign of each component of the Quaternion.
Public method Normalize() Divides each component of a Quaternion by the length of the Quaternion.
Public methodStatic member Normalize(Quaternion) Divides each component of a Quaternion by the length of the Quaternion.
Public methodStatic member Normalize(Quaternion%, Quaternion%) Divides each component of a Quaternion by the length of the Quaternion.
Public methodStatic member Slerp(Quaternion, Quaternion, Single) Interpolates between two Quaternion instances, using spherical linear interpolation.
Public methodStatic member Slerp(Quaternion%, Quaternion%, Single, Quaternion%) Interpolates between two Quaternion instances, using spherical linear interpolation.
Public methodStatic member Subtract(Quaternion, Quaternion) Subtracts a Quaternion from another Quaternion.
Public methodStatic member Subtract(Quaternion%, Quaternion%, Quaternion%) Subtracts a Quaternion from another Quaternion.
Public method ToString Retrieves a string representation of the current object. (Overrides ValueType.ToString().)

Top

Operators

  Name Description
Public operatorStatic member Addition Adds two Quaternion instances.
Public operatorStatic member Division Divides a Quaternion by another Quaternion.
Public operatorStatic member Equality Compares two Quaternion instances for equality.
Public operatorStatic member Inequality Compare two Quaternion instances for inequality.
Public operatorStatic member Multiply(Quaternion, Quaternion) Multiplies two Quaternion instances.
Public operatorStatic member Multiply(Quaternion, Single) Multiplies a Quaternion by a scalar value.
Public operatorStatic member Subtraction Subtracts a Quaternion from another Quaternion.
Public operatorStatic member UnaryNegation Flips the sign of each component of the Quaternion.

Top

Fields

  Name Description
Public field W Specifies the rotation component of the Quaternion.
Public field X Specifies the x-value of the vector component of the Quaternion.
Public field Y Specifies the y-value of the vector component of the Quaternion.
Public field Z Specifies the z-value of the vector component of the Quaternion.

Top

Remarks

Quaternion instances represent a rotation. Typically, they are used for smooth interpolation between two angles, and for avoiding the gimbal lock problem that can occur with euler angles.

Version Information

Silverlight

Supported in: 5

Platforms

For a list of the operating systems and browsers that are supported by Silverlight, see Supported Operating Systems and Browsers.

Thread Safety

Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.