Struct Quaterniond
Represents a double-precision Quaternion.
Inherited Members
Namespace: OpenTK.Mathematics
Assembly: OpenTK.Mathematics.dll
Syntax
[Serializable]
public struct Quaterniond : IEquatable<Quaterniond>, IFormattable
Constructors
Quaterniond(Vector3d)
Initializes a new instance of the Quaterniond struct from given Euler angles in radians.
Declaration
public Quaterniond(Vector3d eulerAngles)
Parameters
Type | Name | Description |
---|---|---|
Vector3d | eulerAngles | The euler angles as a Vector3d. |
Quaterniond(Vector3d, double)
Initializes a new instance of the Quaterniond struct.
Declaration
public Quaterniond(Vector3d v, double w)
Parameters
Type | Name | Description |
---|---|---|
Vector3d | v | The vector part. |
double | w | The w part. |
Quaterniond(double, double, double)
Initializes a new instance of the Quaterniond struct from given Euler angles in radians.
Declaration
public Quaterniond(double pitch, double yaw, double roll)
Parameters
Type | Name | Description |
---|---|---|
double | pitch | The pitch (attitude), rotation around X axis. |
double | yaw | The yaw (heading), rotation around Y axis. |
double | roll | The roll (bank), rotation around Z axis. |
Quaterniond(double, double, double, double)
Initializes a new instance of the Quaterniond struct.
Declaration
public Quaterniond(double x, double y, double z, double w)
Parameters
Type | Name | Description |
---|---|---|
double | x | The x component. |
double | y | The y component. |
double | z | The z component. |
double | w | The w component. |
Fields
Identity
Defines the identity quaternion.
Declaration
public static readonly Quaterniond Identity
Field Value
Type | Description |
---|---|
Quaterniond |
W
The W component of this instance.
Declaration
public double W
Field Value
Type | Description |
---|---|
double |
Xyz
The X, Y and Z components of this instance.
Declaration
public Vector3d Xyz
Field Value
Type | Description |
---|---|
Vector3d |
Properties
Length
Gets the length (magnitude) of the Quaterniond.
Declaration
public readonly double Length { get; }
Property Value
Type | Description |
---|---|
double |
See Also
LengthSquared
Gets the square of the Quaterniond length (magnitude).
Declaration
public readonly double LengthSquared { get; }
Property Value
Type | Description |
---|---|
double |
X
Gets or sets the X component of this instance.
Declaration
public double X { readonly get; set; }
Property Value
Type | Description |
---|---|
double |
Y
Gets or sets the Y component of this instance.
Declaration
public double Y { readonly get; set; }
Property Value
Type | Description |
---|---|
double |
Z
Gets or sets the Z component of this instance.
Declaration
public double Z { readonly get; set; }
Property Value
Type | Description |
---|---|
double |
Methods
Add(Quaterniond, Quaterniond)
Add two quaternions.
Declaration
[Pure]
public static Quaterniond Add(Quaterniond left, Quaterniond right)
Parameters
Type | Name | Description |
---|---|---|
Quaterniond | left | The first operand. |
Quaterniond | right | The second operand. |
Returns
Type | Description |
---|---|
Quaterniond | The result of the addition. |
Add(in Quaterniond, in Quaterniond, out Quaterniond)
Add two quaternions.
Declaration
public static void Add(in Quaterniond left, in Quaterniond right, out Quaterniond result)
Parameters
Type | Name | Description |
---|---|---|
Quaterniond | left | The first operand. |
Quaterniond | right | The second operand. |
Quaterniond | result | The result of the addition. |
Conjugate()
Inverts the Vector3d component of this Quaterniond.
Declaration
public void Conjugate()
Conjugate(Quaterniond)
Get the conjugate of the given Quaterniond.
Declaration
[Pure]
public static Quaterniond Conjugate(Quaterniond q)
Parameters
Type | Name | Description |
---|---|---|
Quaterniond | q | The Quaterniond. |
Returns
Type | Description |
---|---|
Quaterniond | The conjugate of the given Quaterniond. |
Conjugate(in Quaterniond, out Quaterniond)
Get the conjugate of the given Quaterniond.
Declaration
public static void Conjugate(in Quaterniond q, out Quaterniond result)
Parameters
Type | Name | Description |
---|---|---|
Quaterniond | q | The Quaterniond. |
Quaterniond | result | The conjugate of the given Quaterniond. |
Equals(Quaterniond)
Indicates whether the current object is equal to another object of the same type.
Declaration
public readonly bool Equals(Quaterniond other)
Parameters
Type | Name | Description |
---|---|---|
Quaterniond | other | An object to compare with this object. |
Returns
Type | Description |
---|---|
bool | true if the current object is equal to the |
Equals(object)
Indicates whether this instance and a specified object are equal.
Declaration
public override readonly bool Equals(object obj)
Parameters
Type | Name | Description |
---|---|---|
object | obj | The object to compare with the current instance. |
Returns
Type | Description |
---|---|
bool | true if |
Overrides
FromAxisAngle(Vector3d, double)
Build a Quaterniond from the given axis and angle.
Declaration
[Pure]
public static Quaterniond FromAxisAngle(Vector3d axis, double angle)
Parameters
Type | Name | Description |
---|---|---|
Vector3d | axis | The axis to rotate about. |
double | angle | The rotation angle in radians. |
Returns
Type | Description |
---|---|
Quaterniond | The quaternion. |
FromEulerAngles(Vector3d)
Builds a Quaterniond from the given euler angles.
Declaration
[Pure]
public static Quaterniond FromEulerAngles(Vector3d eulerAngles)
Parameters
Type | Name | Description |
---|---|---|
Vector3d | eulerAngles | The euler angles as a vector. |
Returns
Type | Description |
---|---|
Quaterniond | The equivalent Quaterniond. |
FromEulerAngles(in Vector3d, out Quaterniond)
Builds a Quaterniond from the given euler angles.
Declaration
public static void FromEulerAngles(in Vector3d eulerAngles, out Quaterniond result)
Parameters
Type | Name | Description |
---|---|---|
Vector3d | eulerAngles | The euler angles as a vector. |
Quaterniond | result | The equivalent Quaterniond. |
FromEulerAngles(double, double, double)
Builds a Quaterniond from the given euler angles.
Declaration
[Pure]
public static Quaterniond FromEulerAngles(double pitch, double yaw, double roll)
Parameters
Type | Name | Description |
---|---|---|
double | pitch | The pitch (attitude), rotation around X axis. |
double | yaw | The yaw (heading), rotation around Y axis. |
double | roll | The roll (bank), rotation around Z axis. |
Returns
Type | Description |
---|---|
Quaterniond | The quaternion. |
FromMatrix(Matrix3d)
Builds a quaternion from the given rotation matrix.
Declaration
[Pure]
public static Quaterniond FromMatrix(Matrix3d matrix)
Parameters
Type | Name | Description |
---|---|---|
Matrix3d | matrix | A rotation matrix. |
Returns
Type | Description |
---|---|
Quaterniond | The equivalent quaternion. |
FromMatrix(in Matrix3d, out Quaterniond)
Builds a quaternion from the given rotation matrix.
Declaration
public static void FromMatrix(in Matrix3d matrix, out Quaterniond result)
Parameters
Type | Name | Description |
---|---|---|
Matrix3d | matrix | A rotation matrix. |
Quaterniond | result | The equivalent quaternion. |
GetHashCode()
Returns the hash code for this instance.
Declaration
public override readonly int GetHashCode()
Returns
Type | Description |
---|---|
int | A 32-bit signed integer that is the hash code for this instance. |
Overrides
Invert()
Inverts this Quaterniond.
Declaration
public void Invert()
Invert(Quaterniond)
Get the inverse of the given Quaterniond.
Declaration
[Pure]
public static Quaterniond Invert(Quaterniond q)
Parameters
Type | Name | Description |
---|---|---|
Quaterniond | q | The Quaterniond to invert. |
Returns
Type | Description |
---|---|
Quaterniond | The inverse of the given Quaterniond. |
Invert(in Quaterniond, out Quaterniond)
Get the inverse of the given Quaterniond.
Declaration
public static void Invert(in Quaterniond q, out Quaterniond result)
Parameters
Type | Name | Description |
---|---|---|
Quaterniond | q | The Quaterniond to invert. |
Quaterniond | result | The inverse of the given Quaterniond. |
Inverted()
Returns the inverse of this Quaterniond.
Declaration
public readonly Quaterniond Inverted()
Returns
Type | Description |
---|---|
Quaterniond | The inverted copy. |
Multiply(Quaterniond, Quaterniond)
Multiplies two instances.
Declaration
[Pure]
public static Quaterniond Multiply(Quaterniond left, Quaterniond right)
Parameters
Type | Name | Description |
---|---|---|
Quaterniond | left | The first instance. |
Quaterniond | right | The second instance. |
Returns
Type | Description |
---|---|
Quaterniond | A new instance containing the result of the calculation. |
Multiply(Quaterniond, double)
Multiplies an instance by a scalar.
Declaration
[Pure]
public static Quaterniond Multiply(Quaterniond quaternion, double scale)
Parameters
Type | Name | Description |
---|---|---|
Quaterniond | quaternion | The instance. |
double | scale | The scalar. |
Returns
Type | Description |
---|---|
Quaterniond | A new instance containing the result of the calculation. |
Multiply(in Quaterniond, in Quaterniond, out Quaterniond)
Multiplies two instances.
Declaration
public static void Multiply(in Quaterniond left, in Quaterniond right, out Quaterniond result)
Parameters
Type | Name | Description |
---|---|---|
Quaterniond | left | The first instance. |
Quaterniond | right | The second instance. |
Quaterniond | result | A new instance containing the result of the calculation. |
Multiply(in Quaterniond, double, out Quaterniond)
Multiplies an instance by a scalar.
Declaration
public static void Multiply(in Quaterniond quaternion, double scale, out Quaterniond result)
Parameters
Type | Name | Description |
---|---|---|
Quaterniond | quaternion | The instance. |
double | scale | The scalar. |
Quaterniond | result | A new instance containing the result of the calculation. |
Normalize()
Scales the Quaterniond to unit length.
Declaration
public void Normalize()
Normalize(Quaterniond)
Scale the given Quaterniond to unit length.
Declaration
[Pure]
public static Quaterniond Normalize(Quaterniond q)
Parameters
Type | Name | Description |
---|---|---|
Quaterniond | q | The Quaterniond to normalize. |
Returns
Type | Description |
---|---|
Quaterniond | The normalized copy. |
Normalize(in Quaterniond, out Quaterniond)
Scale the given Quaterniond to unit length.
Declaration
public static void Normalize(in Quaterniond q, out Quaterniond result)
Parameters
Type | Name | Description |
---|---|---|
Quaterniond | q | The Quaterniond to normalize. |
Quaterniond | result | The normalized Quaterniond. |
Normalized()
Returns a copy of the Quaterniond scaled to unit length.
Declaration
public readonly Quaterniond Normalized()
Returns
Type | Description |
---|---|
Quaterniond | The normalized copy. |
Slerp(Quaterniond, Quaterniond, double)
Do Spherical linear interpolation between two quaternions.
Declaration
[Pure]
public static Quaterniond Slerp(Quaterniond q1, Quaterniond q2, double blend)
Parameters
Type | Name | Description |
---|---|---|
Quaterniond | q1 | The first Quaterniond. |
Quaterniond | q2 | The second Quaterniond. |
double | blend | The blend factor. |
Returns
Type | Description |
---|---|
Quaterniond | A smooth blend between the given quaternions. |
Sub(Quaterniond, Quaterniond)
Subtracts two instances.
Declaration
[Pure]
public static Quaterniond Sub(Quaterniond left, Quaterniond right)
Parameters
Type | Name | Description |
---|---|---|
Quaterniond | left | The left instance. |
Quaterniond | right | The right instance. |
Returns
Type | Description |
---|---|
Quaterniond | The result of the operation. |
Sub(in Quaterniond, in Quaterniond, out Quaterniond)
Subtracts two instances.
Declaration
public static void Sub(in Quaterniond left, in Quaterniond right, out Quaterniond result)
Parameters
Type | Name | Description |
---|---|---|
Quaterniond | left | The left instance. |
Quaterniond | right | The right instance. |
Quaterniond | result | The result of the operation. |
ToAxisAngle()
Convert this instance to an axis-angle representation.
Declaration
public Vector4d ToAxisAngle()
Returns
Type | Description |
---|---|
Vector4d | A Vector4 that is the axis-angle representation of this quaternion. |
ToAxisAngle(out Vector3d, out double)
Convert the current quaternion to axis angle representation.
Declaration
public void ToAxisAngle(out Vector3d axis, out double angle)
Parameters
Type | Name | Description |
---|---|---|
Vector3d | axis | The resultant axis. |
double | angle | The resultant angle. |
ToEulerAngles()
Convert this instance to an Euler angle representation.
Declaration
public readonly Vector3d ToEulerAngles()
Returns
Type | Description |
---|---|
Vector3d | The Euler angles in radians. |
ToEulerAngles(in Quaterniond, out Vector3d)
Converts a quaternion to it's euler angle representation.
Declaration
public static void ToEulerAngles(in Quaterniond q, out Vector3d result)
Parameters
Type | Name | Description |
---|---|---|
Quaterniond | q | The Quaternion. |
Vector3d | result | The resulting euler angles in radians. |
ToEulerAngles(out Vector3d)
Convert the current quaternion to Euler angle representation.
Declaration
public readonly void ToEulerAngles(out Vector3d angles)
Parameters
Type | Name | Description |
---|---|---|
Vector3d | angles | The Euler angles in radians. |
ToString()
Returns a System.String that represents the current Quaterniond.
Declaration
public override readonly string ToString()
Returns
Type | Description |
---|---|
string | A human-readable representation of the quaternion. |
Overrides
ToString(IFormatProvider)
Formats the value of the current instance using the specified format.
Declaration
public readonly string ToString(IFormatProvider formatProvider)
Parameters
Type | Name | Description |
---|---|---|
IFormatProvider | formatProvider | The provider to use to format the value. -or- A null reference ( |
Returns
Type | Description |
---|---|
string | The value of the current instance in the specified format. |
ToString(string)
Formats the value of the current instance using the specified format.
Declaration
public readonly string ToString(string format)
Parameters
Type | Name | Description |
---|---|---|
string | format | The format to use. -or- A null reference ( |
Returns
Type | Description |
---|---|
string | The value of the current instance in the specified format. |
ToString(string, IFormatProvider)
Formats the value of the current instance using the specified format.
Declaration
public readonly string ToString(string format, IFormatProvider formatProvider)
Parameters
Type | Name | Description |
---|---|---|
string | format | The format to use. -or- A null reference ( |
IFormatProvider | formatProvider | The provider to use to format the value. -or- A null reference ( |
Returns
Type | Description |
---|---|
string | The value of the current instance in the specified format. |
Operators
operator +(Quaterniond, Quaterniond)
Adds two instances.
Declaration
[Pure]
public static Quaterniond operator +(Quaterniond left, Quaterniond right)
Parameters
Type | Name | Description |
---|---|---|
Quaterniond | left | The first instance. |
Quaterniond | right | The second instance. |
Returns
Type | Description |
---|---|
Quaterniond | The result of the calculation. |
operator ==(Quaterniond, Quaterniond)
Compares two instances for equality.
Declaration
public static bool operator ==(Quaterniond left, Quaterniond right)
Parameters
Type | Name | Description |
---|---|---|
Quaterniond | left | The first instance. |
Quaterniond | right | The second instance. |
Returns
Type | Description |
---|---|
bool | True, if left equals right; false otherwise. |
operator !=(Quaterniond, Quaterniond)
Compares two instances for inequality.
Declaration
public static bool operator !=(Quaterniond left, Quaterniond right)
Parameters
Type | Name | Description |
---|---|---|
Quaterniond | left | The first instance. |
Quaterniond | right | The second instance. |
Returns
Type | Description |
---|---|
bool | True, if left does not equal right; false otherwise. |
operator *(Quaterniond, Quaterniond)
Multiplies two instances.
Declaration
[Pure]
public static Quaterniond operator *(Quaterniond left, Quaterniond right)
Parameters
Type | Name | Description |
---|---|---|
Quaterniond | left | The first instance. |
Quaterniond | right | The second instance. |
Returns
Type | Description |
---|---|
Quaterniond | The result of the calculation. |
operator *(Quaterniond, double)
Multiplies an instance by a scalar.
Declaration
[Pure]
public static Quaterniond operator *(Quaterniond quaternion, double scale)
Parameters
Type | Name | Description |
---|---|---|
Quaterniond | quaternion | The instance. |
double | scale | The scalar. |
Returns
Type | Description |
---|---|
Quaterniond | A new instance containing the result of the calculation. |
operator *(double, Quaterniond)
Multiplies an instance by a scalar.
Declaration
[Pure]
public static Quaterniond operator *(double scale, Quaterniond quaternion)
Parameters
Type | Name | Description |
---|---|---|
double | scale | The scalar. |
Quaterniond | quaternion | The instance. |
Returns
Type | Description |
---|---|
Quaterniond | A new instance containing the result of the calculation. |
operator -(Quaterniond, Quaterniond)
Subtracts two instances.
Declaration
[Pure]
public static Quaterniond operator -(Quaterniond left, Quaterniond right)
Parameters
Type | Name | Description |
---|---|---|
Quaterniond | left | The first instance. |
Quaterniond | right | The second instance. |
Returns
Type | Description |
---|---|
Quaterniond | The result of the calculation. |