Quaternion Struct
Namespace: Stride.Core.MathematicsAssembly: Stride.Core.Mathematics.dll
Represents a four dimensional mathematical quaternion.
[DataContract("quaternion")]
[DataStyle(DataStyle.Compact)]
public struct Quaternion : IEquatable<Quaternion>, IFormattable
Name | Description | |
---|---|---|
Constructors | ||
Quaternion(Vector2, Single, Single) | Initializes a new instance of the Quaternion struct. |
|
Quaternion(Vector3, Single) | Initializes a new instance of the Quaternion struct. |
|
Quaternion(Vector4) | Initializes a new instance of the Quaternion struct. |
|
Quaternion(Single) | Initializes a new instance of the Quaternion struct. |
|
Quaternion(Single, Single, Single, Single) | Initializes a new instance of the Quaternion struct. |
|
Quaternion(Single[]) | Initializes a new instance of the Quaternion struct. |
|
Fields | ||
Identity | The identity Quaternion (0, 0, 0, 1). |
|
One | A Quaternion with all of its components set to one. |
|
SizeInBytes | The size of the Quaternion type, in bytes. |
|
W | The W component of the quaternion. |
|
X | The X component of the quaternion. |
|
Y | The Y component of the quaternion. |
|
Z | The Z component of the quaternion. |
|
Zero | A Quaternion with all of its components set to zero. |
|
Properties | ||
Angle | Gets the angle of the quaternion. |
|
Axis | Gets the axis components of the quaternion. |
|
IsIdentity | Gets a value indicating whether this instance is equivalent to the identity quaternion. |
|
IsNormalized | Gets a value indicting whether this instance is normalized. |
|
Item[Int32] | Gets or sets the component at the specified index. |
|
YawPitchRoll | Gets yaw/pitch/roll equivalent of the quaternion |
|
Methods | ||
Add(Quaternion, Quaternion) | Adds two quaternions. |
|
Add(ref Quaternion, ref Quaternion, out Quaternion) | Adds two quaternions. |
|
Barycentric(Quaternion, Quaternion, Quaternion, Single, Single) | Returns a Quaternion containing the 4D Cartesian coordinates of a point specified in Barycentric coordinates relative to a 2D triangle. |
|
Barycentric(ref Quaternion, ref Quaternion, ref Quaternion, Single, Single, out Quaternion) | Returns a Quaternion containing the 4D Cartesian coordinates of a point specified in Barycentric coordinates relative to a 2D triangle. |
|
BetweenDirections(Vector3, Vector3) | Computes a quaternion corresponding to the rotation transforming the vector |
|
BetweenDirections(ref Vector3, ref Vector3, out Quaternion) | Computes a quaternion corresponding to the rotation transforming the vector |
|
Conjugate() | Conjugates the quaternion. |
|
Conjugate(Quaternion) | Conjugates a quaternion. |
|
Conjugate(ref Quaternion, out Quaternion) | Conjugates a quaternion. |
|
Dot(Quaternion, Quaternion) | Calculates the dot product of two quaternions. |
|
Dot(ref Quaternion, ref Quaternion, out Single) | Calculates the dot product of two quaternions. |
|
Equals(Quaternion) | Determines whether the specified Quaternion is equal to this instance. |
|
Equals(Object) | Determines whether the specified System.Object is equal to this instance. |
|
Exponential(Quaternion) | Exponentiates a quaternion. |
|
Exponential(ref Quaternion, out Quaternion) | Exponentiates a quaternion. |
|
GetHashCode() | Returns a hash code for this instance. |
|
Invert() | Conjugates and renormalizes the quaternion. |
|
Invert(Quaternion) | Conjugates and renormalizes the quaternion. |
|
Invert(ref Quaternion, out Quaternion) | Conjugates and renormalizes the quaternion. |
|
Length() | Calculates the length of the quaternion. |
|
LengthSquared() | Calculates the squared length of the quaternion. |
|
Lerp(Quaternion, Quaternion, Single) | Performs a linear interpolation between two quaternion. |
|
Lerp(ref Quaternion, ref Quaternion, Single, out Quaternion) | Performs a linear interpolation between two quaternions. |
|
Logarithm(Quaternion) | Calculates the natural logarithm of the specified quaternion. |
|
Logarithm(ref Quaternion, out Quaternion) | Calculates the natural logarithm of the specified quaternion. |
|
Multiply(Quaternion, Quaternion) | Modulates a quaternion by another. |
|
Multiply(Quaternion, Single) | Scales a quaternion by the given value. |
|
Multiply(ref Quaternion, ref Quaternion, out Quaternion) | Modulates a quaternion by another. |
|
Multiply(ref Quaternion, Single, out Quaternion) | Scales a quaternion by the given value. |
|
Negate(Quaternion) | Reverses the direction of a given quaternion. |
|
Negate(ref Quaternion, out Quaternion) | Reverses the direction of a given quaternion. |
|
Normalize() | Converts the quaternion into a unit quaternion. |
|
Normalize(Quaternion) | Converts the quaternion into a unit quaternion. |
|
Normalize(ref Quaternion, out Quaternion) | Converts the quaternion into a unit quaternion. |
|
Rotate(ref Vector3) | Rotates a Vector3 by the specified quaternion rotation. |
|
RotationAxis(Vector3, Single) | Creates a quaternion given a rotation and an axis. |
|
RotationAxis(ref Vector3, Single, out Quaternion) | Creates a quaternion given a rotation and an axis. |
|
RotationMatrix(Matrix) | Creates a quaternion given a rotation matrix. |
|
RotationMatrix(ref Matrix, out Quaternion) | Creates a quaternion given a rotation matrix. |
|
RotationX(Single) | Creates a quaternion that rotates around the x-axis. |
|
RotationX(Single, out Quaternion) | Creates a quaternion that rotates around the x-axis. |
|
RotationY(Single) | Creates a quaternion that rotates around the y-axis. |
|
RotationY(Single, out Quaternion) | Creates a quaternion that rotates around the y-axis. |
|
RotationYawPitchRoll(ref Quaternion, out Single, out Single, out Single) | Calculate the yaw/pitch/roll rotation equivalent to the provided quaternion. |
|
RotationYawPitchRoll(Single, Single, Single) | Creates a quaternion given a yaw, pitch, and roll value. |
|
RotationYawPitchRoll(Single, Single, Single, out Quaternion) | Creates a quaternion given a yaw, pitch, and roll value (angles in radians). |
|
RotationZ(Single) | Creates a quaternion that rotates around the z-axis. |
|
RotationZ(Single, out Quaternion) | Creates a quaternion that rotates around the z-axis. |
|
Slerp(Quaternion, Quaternion, Single) | Interpolates between two quaternions, using spherical linear interpolation. |
|
Slerp(ref Quaternion, ref Quaternion, Single, out Quaternion) | Interpolates between two quaternions, using spherical linear interpolation. |
|
Squad(Quaternion, Quaternion, Quaternion, Quaternion, Single) | Interpolates between quaternions, using spherical quadrangle interpolation. |
|
Squad(ref Quaternion, ref Quaternion, ref Quaternion, ref Quaternion, Single, out Quaternion) | Interpolates between quaternions, using spherical quadrangle interpolation. |
|
SquadSetup(Quaternion, Quaternion, Quaternion, Quaternion) | Sets up control points for spherical quadrangle interpolation. |
|
Subtract(Quaternion, Quaternion) | Subtracts two quaternions. |
|
Subtract(ref Quaternion, ref Quaternion, out Quaternion) | Subtracts two quaternions. |
|
ToArray() | Creates an array containing the elements of the quaternion. |
|
ToString() | Returns a System.String that represents this instance. |
|
ToString(IFormatProvider) | Returns a System.String that represents this instance. |
|
ToString(String) | Returns a System.String that represents this instance. |
|
ToString(String, IFormatProvider) | Returns a System.String that represents this instance. |
|
Operators | ||
Addition(Quaternion, Quaternion) | Adds two quaternions. |
|
Equality(Quaternion, Quaternion) | Tests for equality between two objects. |
|
Inequality(Quaternion, Quaternion) | Tests for inequality between two objects. |
|
Multiply(Quaternion, Quaternion) | Multiplies a quaternion by another. |
|
Multiply(Quaternion, Single) | Scales a quaternion by the given value. |
|
Multiply(Single, Quaternion) | Scales a quaternion by the given value. |
|
Subtraction(Quaternion, Quaternion) | Subtracts two quaternions. |
|
UnaryNegation(Quaternion) | Reverses the direction of a given quaternion. |
Constructors
Quaternion(Vector2, Single, Single)
Initializes a new instance of the Quaternion struct.
public Quaternion(Vector2 value, float z, float w)
Parameters
Type | Name | Description |
---|---|---|
Vector2 | value | A vector containing the values with which to initialize the X and Y components. |
System.Single | z | Initial value for the Z component of the quaternion. |
System.Single | w | Initial value for the W component of the quaternion. |
Quaternion(Vector3, Single)
Initializes a new instance of the Quaternion struct.
public Quaternion(Vector3 value, float w)
Parameters
Type | Name | Description |
---|---|---|
Vector3 | value | A vector containing the values with which to initialize the X, Y, and Z components. |
System.Single | w | Initial value for the W component of the quaternion. |
Quaternion(Vector4)
Initializes a new instance of the Quaternion struct.
public Quaternion(Vector4 value)
Parameters
Type | Name | Description |
---|---|---|
Vector4 | value | A vector containing the values with which to initialize the components. |
Quaternion(Single)
Initializes a new instance of the Quaternion struct.
public Quaternion(float value)
Parameters
Type | Name | Description |
---|---|---|
System.Single | value | The value that will be assigned to all components. |
Quaternion(Single, Single, Single, Single)
Initializes a new instance of the Quaternion struct.
public Quaternion(float x, float y, float z, float w)
Parameters
Type | Name | Description |
---|---|---|
System.Single | x | Initial value for the X component of the quaternion. |
System.Single | y | Initial value for the Y component of the quaternion. |
System.Single | z | Initial value for the Z component of the quaternion. |
System.Single | w | Initial value for the W component of the quaternion. |
Quaternion(Single[])
Initializes a new instance of the Quaternion struct.
public Quaternion(float[] values)
Parameters
Type | Name | Description |
---|---|---|
System.Single[] | values | The values to assign to the X, Y, Z, and W components of the quaternion. This must be an array with four elements. |
Exceptions
Type | Condition |
---|---|
System.ArgumentNullException | Thrown when |
System.ArgumentOutOfRangeException | Thrown when |
Fields
Identity
The identity Quaternion (0, 0, 0, 1).
public static readonly Quaternion Identity
Field Value
Type | Description |
---|---|
Quaternion |
One
A Quaternion with all of its components set to one.
public static readonly Quaternion One
Field Value
Type | Description |
---|---|
Quaternion |
SizeInBytes
The size of the Quaternion type, in bytes.
public static readonly int SizeInBytes
Field Value
Type | Description |
---|---|
System.Int32 |
W
The W component of the quaternion.
public float W
Field Value
Type | Description |
---|---|
System.Single |
X
The X component of the quaternion.
public float X
Field Value
Type | Description |
---|---|
System.Single |
Y
The Y component of the quaternion.
public float Y
Field Value
Type | Description |
---|---|
System.Single |
Z
The Z component of the quaternion.
public float Z
Field Value
Type | Description |
---|---|
System.Single |
Zero
A Quaternion with all of its components set to zero.
public static readonly Quaternion Zero
Field Value
Type | Description |
---|---|
Quaternion |
Properties
Angle
Gets the angle of the quaternion.
public readonly float Angle { get; }
Property Value
Type | Description |
---|---|
System.Single | The quaternion's angle. |
Axis
Gets the axis components of the quaternion.
public readonly Vector3 Axis { get; }
Property Value
Type | Description |
---|---|
Vector3 | The axis components of the quaternion. |
IsIdentity
Gets a value indicating whether this instance is equivalent to the identity quaternion.
public readonly bool IsIdentity { get; }
Property Value
Type | Description |
---|---|
System.Boolean |
|
IsNormalized
Gets a value indicting whether this instance is normalized.
public readonly bool IsNormalized { get; }
Property Value
Type | Description |
---|---|
System.Boolean |
Item[Int32]
Gets or sets the component at the specified index.
public float this[int index] { get; set; }
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | index | The index of the component to access. Use 0 for the X component, 1 for the Y component, 2 for the Z component, and 3 for the W component. |
Property Value
Type | Description |
---|---|
System.Single | The value of the X, Y, Z, or W component, depending on the index. |
Exceptions
Type | Condition |
---|---|
System.ArgumentOutOfRangeException | Thrown when the |
YawPitchRoll
Gets yaw/pitch/roll equivalent of the quaternion
public readonly Vector3 YawPitchRoll { get; }
Property Value
Type | Description |
---|---|
Vector3 |
Methods
Add(Quaternion, Quaternion)
Adds two quaternions.
public static Quaternion Add(Quaternion left, Quaternion right)
Parameters
Type | Name | Description |
---|---|---|
Quaternion | left | The first quaternion to add. |
Quaternion | right | The second quaternion to add. |
Returns
Type | Description |
---|---|
Quaternion | The sum of the two quaternions. |
Add(ref Quaternion, ref Quaternion, out Quaternion)
Adds two quaternions.
public static void Add(ref Quaternion left, ref Quaternion right, out Quaternion result)
Parameters
Type | Name | Description |
---|---|---|
Quaternion | left | The first quaternion to add. |
Quaternion | right | The second quaternion to add. |
Quaternion | result | When the method completes, contains the sum of the two quaternions. |
Barycentric(Quaternion, Quaternion, Quaternion, Single, Single)
Returns a Quaternion containing the 4D Cartesian coordinates of a point specified in Barycentric coordinates relative to a 2D triangle.
public static Quaternion Barycentric(Quaternion value1, Quaternion value2, Quaternion value3, float amount1, float amount2)
Parameters
Type | Name | Description |
---|---|---|
Quaternion | value1 | A Quaternion containing the 4D Cartesian coordinates of vertex 1 of the triangle. |
Quaternion | value2 | A Quaternion containing the 4D Cartesian coordinates of vertex 2 of the triangle. |
Quaternion | value3 | A Quaternion containing the 4D Cartesian coordinates of vertex 3 of the triangle. |
System.Single | amount1 | Barycentric coordinate b2, which expresses the weighting factor toward vertex 2 (specified in |
System.Single | amount2 | Barycentric coordinate b3, which expresses the weighting factor toward vertex 3 (specified in |
Returns
Type | Description |
---|---|
Quaternion | A new Quaternion containing the 4D Cartesian coordinates of the specified point. |
Barycentric(ref Quaternion, ref Quaternion, ref Quaternion, Single, Single, out Quaternion)
Returns a Quaternion containing the 4D Cartesian coordinates of a point specified in Barycentric coordinates relative to a 2D triangle.
public static void Barycentric(ref Quaternion value1, ref Quaternion value2, ref Quaternion value3, float amount1, float amount2, out Quaternion result)
Parameters
Type | Name | Description |
---|---|---|
Quaternion | value1 | A Quaternion containing the 4D Cartesian coordinates of vertex 1 of the triangle. |
Quaternion | value2 | A Quaternion containing the 4D Cartesian coordinates of vertex 2 of the triangle. |
Quaternion | value3 | A Quaternion containing the 4D Cartesian coordinates of vertex 3 of the triangle. |
System.Single | amount1 | Barycentric coordinate b2, which expresses the weighting factor toward vertex 2 (specified in |
System.Single | amount2 | Barycentric coordinate b3, which expresses the weighting factor toward vertex 3 (specified in |
Quaternion | result | When the method completes, contains a new Quaternion containing the 4D Cartesian coordinates of the specified point. |
BetweenDirections(Vector3, Vector3)
Computes a quaternion corresponding to the rotation transforming the vector source
to the vector target
.
public static Quaternion BetweenDirections(Vector3 source, Vector3 target)
Parameters
Type | Name | Description |
---|---|---|
Vector3 | source | The source vector of the transformation. |
Vector3 | target | The target vector of the transformation. |
Returns
Type | Description |
---|---|
Quaternion | The resulting quaternion corresponding to the transformation of the source vector to the target vector. |
BetweenDirections(ref Vector3, ref Vector3, out Quaternion)
Computes a quaternion corresponding to the rotation transforming the vector source
to the vector target
.
public static void BetweenDirections(ref Vector3 source, ref Vector3 target, out Quaternion result)
Parameters
Type | Name | Description |
---|---|---|
Vector3 | source | The source vector of the transformation. |
Vector3 | target | The target vector of the transformation. |
Quaternion | result | The resulting quaternion corresponding to the transformation of the source vector to the target vector. |
Conjugate()
Conjugates the quaternion.
public void Conjugate()
Conjugate(Quaternion)
Conjugates a quaternion.
public static Quaternion Conjugate(Quaternion value)
Parameters
Type | Name | Description |
---|---|---|
Quaternion | value | The quaternion to conjugate. |
Returns
Type | Description |
---|---|
Quaternion | The conjugated quaternion. |
Conjugate(ref Quaternion, out Quaternion)
Conjugates a quaternion.
public static void Conjugate(ref Quaternion value, out Quaternion result)
Parameters
Type | Name | Description |
---|---|---|
Quaternion | value | The quaternion to conjugate. |
Quaternion | result | When the method completes, contains the conjugated quaternion. |
Dot(Quaternion, Quaternion)
Calculates the dot product of two quaternions.
public static float Dot(Quaternion left, Quaternion right)
Parameters
Type | Name | Description |
---|---|---|
Quaternion | left | First source quaternion. |
Quaternion | right | Second source quaternion. |
Returns
Type | Description |
---|---|
System.Single | The dot product of the two quaternions. |
Dot(ref Quaternion, ref Quaternion, out Single)
Calculates the dot product of two quaternions.
public static void Dot(ref Quaternion left, ref Quaternion right, out float result)
Parameters
Type | Name | Description |
---|---|---|
Quaternion | left | First source quaternion. |
Quaternion | right | Second source quaternion. |
System.Single | result | When the method completes, contains the dot product of the two quaternions. |
Equals(Quaternion)
Determines whether the specified Quaternion is equal to this instance.
public bool Equals(Quaternion other)
Parameters
Type | Name | Description |
---|---|---|
Quaternion | other | The Quaternion to compare with this instance. |
Returns
Type | Description |
---|---|
System.Boolean |
|
Equals(Object)
Determines whether the specified System.Object is equal to this instance.
public override bool Equals(object value)
Parameters
Type | Name | Description |
---|---|---|
System.Object | value | The System.Object to compare with this instance. |
Returns
Type | Description |
---|---|
System.Boolean |
|
Overrides
Exponential(Quaternion)
Exponentiates a quaternion.
public static Quaternion Exponential(Quaternion value)
Parameters
Type | Name | Description |
---|---|---|
Quaternion | value | The quaternion to exponentiate. |
Returns
Type | Description |
---|---|
Quaternion | The exponentiated quaternion. |
Exponential(ref Quaternion, out Quaternion)
Exponentiates a quaternion.
public static void Exponential(ref Quaternion value, out Quaternion result)
Parameters
Type | Name | Description |
---|---|---|
Quaternion | value | The quaternion to exponentiate. |
Quaternion | result | When the method completes, contains the exponentiated quaternion. |
GetHashCode()
Returns a hash code for this instance.
public override int GetHashCode()
Returns
Type | Description |
---|---|
System.Int32 | A hash code for this instance, suitable for use in hashing algorithms and data structures like a hash table. |
Overrides
Invert()
Conjugates and renormalizes the quaternion.
public void Invert()
Invert(Quaternion)
Conjugates and renormalizes the quaternion.
public static Quaternion Invert(Quaternion value)
Parameters
Type | Name | Description |
---|---|---|
Quaternion | value | The quaternion to conjugate and renormalize. |
Returns
Type | Description |
---|---|
Quaternion | The conjugated and renormalized quaternion. |
Invert(ref Quaternion, out Quaternion)
Conjugates and renormalizes the quaternion.
public static void Invert(ref Quaternion value, out Quaternion result)
Parameters
Type | Name | Description |
---|---|---|
Quaternion | value | The quaternion to conjugate and renormalize. |
Quaternion | result | When the method completes, contains the conjugated and renormalized quaternion. |
Length()
Calculates the length of the quaternion.
public float Length()
Returns
Type | Description |
---|---|
System.Single | The length of the quaternion. |
Remarks
LengthSquared() may be preferred when only the relative length is needed and speed is of the essence.
LengthSquared()
Calculates the squared length of the quaternion.
public float LengthSquared()
Returns
Type | Description |
---|---|
System.Single | The squared length of the quaternion. |
Remarks
This method may be preferred to Length() when only a relative length is needed and speed is of the essence.
Lerp(Quaternion, Quaternion, Single)
Performs a linear interpolation between two quaternion.
public static Quaternion Lerp(Quaternion start, Quaternion end, float amount)
Parameters
Type | Name | Description |
---|---|---|
Quaternion | start | Start quaternion. |
Quaternion | end | End quaternion. |
System.Single | amount | Value between 0 and 1 indicating the weight of |
Returns
Type | Description |
---|---|
Quaternion | The linear interpolation of the two quaternions. |
Remarks
This method performs the linear interpolation based on the following formula.
start + (end - start) * amount
Passing amount
a value of 0 will cause start
to be returned; a value of 1 will cause end
to be returned.
Lerp(ref Quaternion, ref Quaternion, Single, out Quaternion)
Performs a linear interpolation between two quaternions.
public static void Lerp(ref Quaternion start, ref Quaternion end, float amount, out Quaternion result)
Parameters
Type | Name | Description |
---|---|---|
Quaternion | start | Start quaternion. |
Quaternion | end | End quaternion. |
System.Single | amount | Value between 0 and 1 indicating the weight of |
Quaternion | result | When the method completes, contains the linear interpolation of the two quaternions. |
Remarks
This method performs the linear interpolation based on the following formula.
start + (end - start) * amount
Passing amount
a value of 0 will cause start
to be returned; a value of 1 will cause end
to be returned.
Logarithm(Quaternion)
Calculates the natural logarithm of the specified quaternion.
public static Quaternion Logarithm(Quaternion value)
Parameters
Type | Name | Description |
---|---|---|
Quaternion | value | The quaternion whose logarithm will be calculated. |
Returns
Type | Description |
---|---|
Quaternion | The natural logarithm of the quaternion. |
Logarithm(ref Quaternion, out Quaternion)
Calculates the natural logarithm of the specified quaternion.
public static void Logarithm(ref Quaternion value, out Quaternion result)
Parameters
Type | Name | Description |
---|---|---|
Quaternion | value | The quaternion whose logarithm will be calculated. |
Quaternion | result | When the method completes, contains the natural logarithm of the quaternion. |
Multiply(Quaternion, Quaternion)
Modulates a quaternion by another.
public static Quaternion Multiply(Quaternion left, Quaternion right)
Parameters
Type | Name | Description |
---|---|---|
Quaternion | left | The first quaternion to modulate. |
Quaternion | right | The second quaternion to modulate. |
Returns
Type | Description |
---|---|
Quaternion | The modulated quaternion. |
Multiply(Quaternion, Single)
Scales a quaternion by the given value.
public static Quaternion Multiply(Quaternion value, float scale)
Parameters
Type | Name | Description |
---|---|---|
Quaternion | value | The quaternion to scale. |
System.Single | scale | The amount by which to scale the quaternion. |
Returns
Type | Description |
---|---|
Quaternion | The scaled quaternion. |
Multiply(ref Quaternion, ref Quaternion, out Quaternion)
Modulates a quaternion by another.
public static void Multiply(ref Quaternion left, ref Quaternion right, out Quaternion result)
Parameters
Type | Name | Description |
---|---|---|
Quaternion | left | The first quaternion to modulate. |
Quaternion | right | The second quaternion to modulate. |
Quaternion | result | When the moethod completes, contains the modulated quaternion. |
Multiply(ref Quaternion, Single, out Quaternion)
Scales a quaternion by the given value.
public static void Multiply(ref Quaternion value, float scale, out Quaternion result)
Parameters
Type | Name | Description |
---|---|---|
Quaternion | value | The quaternion to scale. |
System.Single | scale | The amount by which to scale the quaternion. |
Quaternion | result | When the method completes, contains the scaled quaternion. |
Negate(Quaternion)
Reverses the direction of a given quaternion.
public static Quaternion Negate(Quaternion value)
Parameters
Type | Name | Description |
---|---|---|
Quaternion | value | The quaternion to negate. |
Returns
Type | Description |
---|---|
Quaternion | A quaternion facing in the opposite direction. |
Negate(ref Quaternion, out Quaternion)
Reverses the direction of a given quaternion.
public static void Negate(ref Quaternion value, out Quaternion result)
Parameters
Type | Name | Description |
---|---|---|
Quaternion | value | The quaternion to negate. |
Quaternion | result | When the method completes, contains a quaternion facing in the opposite direction. |
Normalize()
Converts the quaternion into a unit quaternion.
public void Normalize()
Normalize(Quaternion)
Converts the quaternion into a unit quaternion.
public static Quaternion Normalize(Quaternion value)
Parameters
Type | Name | Description |
---|---|---|
Quaternion | value | The quaternion to normalize. |
Returns
Type | Description |
---|---|
Quaternion | The normalized quaternion. |
Normalize(ref Quaternion, out Quaternion)
Converts the quaternion into a unit quaternion.
public static void Normalize(ref Quaternion value, out Quaternion result)
Parameters
Type | Name | Description |
---|---|---|
Quaternion | value | The quaternion to normalize. |
Quaternion | result | When the method completes, contains the normalized quaternion. |
Rotate(ref Vector3)
Rotates a Vector3 by the specified quaternion rotation.
public void Rotate(ref Vector3 vector)
Parameters
Type | Name | Description |
---|---|---|
Vector3 | vector | The vector to rotate. |
RotationAxis(Vector3, Single)
Creates a quaternion given a rotation and an axis.
public static Quaternion RotationAxis(Vector3 axis, float angle)
Parameters
Type | Name | Description |
---|---|---|
Vector3 | axis | The axis of rotation. |
System.Single | angle | The angle of rotation. |
Returns
Type | Description |
---|---|
Quaternion | The newly created quaternion. |
RotationAxis(ref Vector3, Single, out Quaternion)
Creates a quaternion given a rotation and an axis.
public static void RotationAxis(ref Vector3 axis, float angle, out Quaternion result)
Parameters
Type | Name | Description |
---|---|---|
Vector3 | axis | The axis of rotation. |
System.Single | angle | The angle of rotation. |
Quaternion | result | When the method completes, contains the newly created quaternion. |
RotationMatrix(Matrix)
Creates a quaternion given a rotation matrix.
public static Quaternion RotationMatrix(Matrix matrix)
Parameters
Type | Name | Description |
---|---|---|
Matrix | matrix | The rotation matrix. |
Returns
Type | Description |
---|---|
Quaternion | The newly created quaternion. |
RotationMatrix(ref Matrix, out Quaternion)
Creates a quaternion given a rotation matrix.
public static void RotationMatrix(ref Matrix matrix, out Quaternion result)
Parameters
Type | Name | Description |
---|---|---|
Matrix | matrix | The rotation matrix. |
Quaternion | result | When the method completes, contains the newly created quaternion. |
RotationX(Single)
Creates a quaternion that rotates around the x-axis.
public static Quaternion RotationX(float angle)
Parameters
Type | Name | Description |
---|---|---|
System.Single | angle | Angle of rotation in radians. |
Returns
Type | Description |
---|---|
Quaternion | The created rotation quaternion. |
RotationX(Single, out Quaternion)
Creates a quaternion that rotates around the x-axis.
public static void RotationX(float angle, out Quaternion result)
Parameters
Type | Name | Description |
---|---|---|
System.Single | angle | Angle of rotation in radians. |
Quaternion | result | When the method completes, contains the newly created quaternion. |
RotationY(Single)
Creates a quaternion that rotates around the y-axis.
public static Quaternion RotationY(float angle)
Parameters
Type | Name | Description |
---|---|---|
System.Single | angle | Angle of rotation in radians. |
Returns
Type | Description |
---|---|
Quaternion | The created rotation quaternion. |
RotationY(Single, out Quaternion)
Creates a quaternion that rotates around the y-axis.
public static void RotationY(float angle, out Quaternion result)
Parameters
Type | Name | Description |
---|---|---|
System.Single | angle | Angle of rotation in radians. |
Quaternion | result | When the method completes, contains the newly created quaternion. |
RotationYawPitchRoll(ref Quaternion, out Single, out Single, out Single)
Calculate the yaw/pitch/roll rotation equivalent to the provided quaternion.
public static void RotationYawPitchRoll(ref Quaternion rotation, out float yaw, out float pitch, out float roll)
Parameters
Type | Name | Description |
---|---|---|
Quaternion | rotation | The input quaternion |
System.Single | yaw | The yaw component |
System.Single | pitch | The pitch component |
System.Single | roll | The roll component |
RotationYawPitchRoll(Single, Single, Single)
Creates a quaternion given a yaw, pitch, and roll value.
public static Quaternion RotationYawPitchRoll(float yaw, float pitch, float roll)
Parameters
Type | Name | Description |
---|---|---|
System.Single | yaw | The yaw of rotation. |
System.Single | pitch | The pitch of rotation. |
System.Single | roll | The roll of rotation. |
Returns
Type | Description |
---|---|
Quaternion | The newly created quaternion. |
RotationYawPitchRoll(Single, Single, Single, out Quaternion)
Creates a quaternion given a yaw, pitch, and roll value (angles in radians).
public static void RotationYawPitchRoll(float yaw, float pitch, float roll, out Quaternion result)
Parameters
Type | Name | Description |
---|---|---|
System.Single | yaw | The yaw of rotation in radians. |
System.Single | pitch | The pitch of rotation in radians. |
System.Single | roll | The roll of rotation in radians. |
Quaternion | result | When the method completes, contains the newly created quaternion. |
RotationZ(Single)
Creates a quaternion that rotates around the z-axis.
public static Quaternion RotationZ(float angle)
Parameters
Type | Name | Description |
---|---|---|
System.Single | angle | Angle of rotation in radians. |
Returns
Type | Description |
---|---|
Quaternion | The created rotation quaternion. |
RotationZ(Single, out Quaternion)
Creates a quaternion that rotates around the z-axis.
public static void RotationZ(float angle, out Quaternion result)
Parameters
Type | Name | Description |
---|---|---|
System.Single | angle | Angle of rotation in radians. |
Quaternion | result | When the method completes, contains the newly created quaternion. |
Slerp(Quaternion, Quaternion, Single)
Interpolates between two quaternions, using spherical linear interpolation.
public static Quaternion Slerp(Quaternion start, Quaternion end, float amount)
Parameters
Type | Name | Description |
---|---|---|
Quaternion | start | Start quaternion. |
Quaternion | end | End quaternion. |
System.Single | amount | Value between 0 and 1 indicating the weight of |
Returns
Type | Description |
---|---|
Quaternion | The spherical linear interpolation of the two quaternions. |
Slerp(ref Quaternion, ref Quaternion, Single, out Quaternion)
Interpolates between two quaternions, using spherical linear interpolation.
public static void Slerp(ref Quaternion start, ref Quaternion end, float amount, out Quaternion result)
Parameters
Type | Name | Description |
---|---|---|
Quaternion | start | Start quaternion. |
Quaternion | end | End quaternion. |
System.Single | amount | Value between 0 and 1 indicating the weight of |
Quaternion | result | When the method completes, contains the spherical linear interpolation of the two quaternions. |
Squad(Quaternion, Quaternion, Quaternion, Quaternion, Single)
Interpolates between quaternions, using spherical quadrangle interpolation.
public static Quaternion Squad(Quaternion value1, Quaternion value2, Quaternion value3, Quaternion value4, float amount)
Parameters
Type | Name | Description |
---|---|---|
Quaternion | value1 | First source quaternion. |
Quaternion | value2 | Second source quaternion. |
Quaternion | value3 | Thrid source quaternion. |
Quaternion | value4 | Fourth source quaternion. |
System.Single | amount | Value between 0 and 1 indicating the weight of interpolation. |
Returns
Type | Description |
---|---|
Quaternion | The spherical quadrangle interpolation of the quaternions. |
Squad(ref Quaternion, ref Quaternion, ref Quaternion, ref Quaternion, Single, out Quaternion)
Interpolates between quaternions, using spherical quadrangle interpolation.
public static void Squad(ref Quaternion value1, ref Quaternion value2, ref Quaternion value3, ref Quaternion value4, float amount, out Quaternion result)
Parameters
Type | Name | Description |
---|---|---|
Quaternion | value1 | First source quaternion. |
Quaternion | value2 | Second source quaternion. |
Quaternion | value3 | Thrid source quaternion. |
Quaternion | value4 | Fourth source quaternion. |
System.Single | amount | Value between 0 and 1 indicating the weight of interpolation. |
Quaternion | result | When the method completes, contains the spherical quadrangle interpolation of the quaternions. |
SquadSetup(Quaternion, Quaternion, Quaternion, Quaternion)
Sets up control points for spherical quadrangle interpolation.
public static Quaternion[] SquadSetup(Quaternion value1, Quaternion value2, Quaternion value3, Quaternion value4)
Parameters
Type | Name | Description |
---|---|---|
Quaternion | value1 | First source quaternion. |
Quaternion | value2 | Second source quaternion. |
Quaternion | value3 | Third source quaternion. |
Quaternion | value4 | Fourth source quaternion. |
Returns
Type | Description |
---|---|
Quaternion[] | An array of three quaternions that represent control points for spherical quadrangle interpolation. |
Subtract(Quaternion, Quaternion)
Subtracts two quaternions.
public static Quaternion Subtract(Quaternion left, Quaternion right)
Parameters
Type | Name | Description |
---|---|---|
Quaternion | left | The first quaternion to subtract. |
Quaternion | right | The second quaternion to subtract. |
Returns
Type | Description |
---|---|
Quaternion | The difference of the two quaternions. |
Subtract(ref Quaternion, ref Quaternion, out Quaternion)
Subtracts two quaternions.
public static void Subtract(ref Quaternion left, ref Quaternion right, out Quaternion result)
Parameters
Type | Name | Description |
---|---|---|
Quaternion | left | The first quaternion to subtract. |
Quaternion | right | The second quaternion to subtract. |
Quaternion | result | When the method completes, contains the difference of the two quaternions. |
ToArray()
Creates an array containing the elements of the quaternion.
public float[] ToArray()
Returns
Type | Description |
---|---|
System.Single[] | A four-element array containing the components of the quaternion. |
ToString()
Returns a System.String that represents this instance.
public override string ToString()
Returns
Type | Description |
---|---|
System.String | A System.String that represents this instance. |
Overrides
ToString(IFormatProvider)
Returns a System.String that represents this instance.
public string ToString(IFormatProvider formatProvider)
Parameters
Type | Name | Description |
---|---|---|
System.IFormatProvider | formatProvider | The format provider. |
Returns
Type | Description |
---|---|
System.String | A System.String that represents this instance. |
ToString(String)
Returns a System.String that represents this instance.
public string ToString(string format)
Parameters
Type | Name | Description |
---|---|---|
System.String | format | The format. |
Returns
Type | Description |
---|---|
System.String | A System.String that represents this instance. |
ToString(String, IFormatProvider)
Returns a System.String that represents this instance.
public string ToString(string format, IFormatProvider formatProvider)
Parameters
Type | Name | Description |
---|---|---|
System.String | format | The format. |
System.IFormatProvider | formatProvider | The format provider. |
Returns
Type | Description |
---|---|
System.String | A System.String that represents this instance. |
Operators
Addition(Quaternion, Quaternion)
Adds two quaternions.
public static Quaternion operator +(Quaternion left, Quaternion right)
Parameters
Type | Name | Description |
---|---|---|
Quaternion | left | The first quaternion to add. |
Quaternion | right | The second quaternion to add. |
Returns
Type | Description |
---|---|
Quaternion | The sum of the two quaternions. |
Equality(Quaternion, Quaternion)
Tests for equality between two objects.
public static bool operator ==(Quaternion left, Quaternion right)
Parameters
Type | Name | Description |
---|---|---|
Quaternion | left | The first value to compare. |
Quaternion | right | The second value to compare. |
Returns
Type | Description |
---|---|
System.Boolean |
|
Inequality(Quaternion, Quaternion)
Tests for inequality between two objects.
public static bool operator !=(Quaternion left, Quaternion right)
Parameters
Type | Name | Description |
---|---|---|
Quaternion | left | The first value to compare. |
Quaternion | right | The second value to compare. |
Returns
Type | Description |
---|---|
System.Boolean |
|
Multiply(Quaternion, Quaternion)
Multiplies a quaternion by another.
public static Quaternion operator *(Quaternion left, Quaternion right)
Parameters
Type | Name | Description |
---|---|---|
Quaternion | left | The first quaternion to multiply. |
Quaternion | right | The second quaternion to multiply. |
Returns
Type | Description |
---|---|
Quaternion | The multiplied quaternion. |
Multiply(Quaternion, Single)
Scales a quaternion by the given value.
public static Quaternion operator *(Quaternion value, float scale)
Parameters
Type | Name | Description |
---|---|---|
Quaternion | value | The quaternion to scale. |
System.Single | scale | The amount by which to scale the quaternion. |
Returns
Type | Description |
---|---|
Quaternion | The scaled quaternion. |
Multiply(Single, Quaternion)
Scales a quaternion by the given value.
public static Quaternion operator *(float scale, Quaternion value)
Parameters
Type | Name | Description |
---|---|---|
System.Single | scale | The amount by which to scale the quaternion. |
Quaternion | value | The quaternion to scale. |
Returns
Type | Description |
---|---|
Quaternion | The scaled quaternion. |
Subtraction(Quaternion, Quaternion)
Subtracts two quaternions.
public static Quaternion operator -(Quaternion left, Quaternion right)
Parameters
Type | Name | Description |
---|---|---|
Quaternion | left | The first quaternion to subtract. |
Quaternion | right | The second quaternion to subtract. |
Returns
Type | Description |
---|---|
Quaternion | The difference of the two quaternions. |
UnaryNegation(Quaternion)
Reverses the direction of a given quaternion.
public static Quaternion operator -(Quaternion value)
Parameters
Type | Name | Description |
---|---|---|
Quaternion | value | The quaternion to negate. |
Returns
Type | Description |
---|---|
Quaternion | A quaternion facing in the opposite direction. |