Struct Quaterniond
Represents a double-precision Quaternion.
Implements
Inherited Members
Namespace: OpenTK
Assembly: OpenTK.dll
Syntax
[Serializable]
public struct Quaterniond : IEquatable<Quaterniond>
Constructors
Quaterniond(Vector3d)
Construct a new Quaterniond from given Euler angles
Declaration
public Quaterniond(Vector3d eulerAngles)
Parameters
Type | Name | Description |
---|---|---|
Vector3d | eulerAngles | The euler angles as a Vector3d |
Quaterniond(Vector3d, Double)
Construct a new Quaterniond from vector and w components
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)
Construct a new Quaterniond from given Euler angles
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)
Construct a new Quaterniond
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 { get; set; }
Property Value
Type | Description |
---|---|
Double |
Y
Gets or sets the Y component of this instance.
Declaration
public double Y { get; set; }
Property Value
Type | Description |
---|---|
Double |
Z
Gets or sets the Z component of this instance.
Declaration
public double Z { get; set; }
Property Value
Type | Description |
---|---|
Double |
Methods
Add(Quaterniond, Quaterniond)
Add two quaternions
Declaration
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(ref Quaterniond, ref Quaterniond, out Quaterniond)
Add two quaternions
Declaration
public static void Add(ref Quaterniond left, ref 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
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(ref Quaterniond, out Quaterniond)
Get the conjugate of the given Quaterniond
Declaration
public static void Conjugate(ref Quaterniond q, out Quaterniond result)
Parameters
Type | Name | Description |
---|---|---|
Quaterniond | q | The Quaterniond |
Quaterniond | result | The conjugate of the given Quaterniond |
Equals(Quaterniond)
Compares this Quaterniond instance to another Quaterniond for equality.
Declaration
public bool Equals(Quaterniond other)
Parameters
Type | Name | Description |
---|---|---|
Quaterniond | other | The other Quaterniond to be used in the comparison. |
Returns
Type | Description |
---|---|
Boolean | True if both instances are equal; false otherwise. |
Equals(Object)
Compares this object instance to another object for equality.
Declaration
public override bool Equals(object other)
Parameters
Type | Name | Description |
---|---|---|
Object | other | The other object to be used in the comparison. |
Returns
Type | Description |
---|---|
Boolean | True if both objects are Quaternions of equal value. Otherwise it returns false. |
Overrides
FromAxisAngle(Vector3d, Double)
Build a Quaterniond from the given axis and angle
Declaration
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 |
FromEulerAngles(Vector3d)
Builds a Quaterniond from the given euler angles
Declaration
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(ref Vector3d, out Quaterniond)
Builds a Quaterniond from the given euler angles
Declaration
public static void FromEulerAngles(ref Vector3d eulerAngles, out Quaterniond result)
Parameters
Type | Name | Description |
---|---|---|
Vector3d | eulerAngles | The euler angles a vector |
Quaterniond | result | The equivalent Quaterniond |
FromEulerAngles(Double, Double, Double)
Builds a Quaterniond from the given euler angles
Declaration
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 |
FromMatrix(Matrix3d)
Builds a quaternion from the given rotation matrix
Declaration
public static Quaterniond FromMatrix(Matrix3d matrix)
Parameters
Type | Name | Description |
---|---|---|
Matrix3d | matrix | A rotation matrix |
Returns
Type | Description |
---|---|
Quaterniond | The equivalent quaternion |
FromMatrix(ref Matrix3d, out Quaterniond)
Builds a quaternion from the given rotation matrix
Declaration
public static void FromMatrix(ref Matrix3d matrix, out Quaterniond result)
Parameters
Type | Name | Description |
---|---|---|
Matrix3d | matrix | A rotation matrix |
Quaterniond | result | The equivalent quaternion |
GetHashCode()
Provides the hash code for this object.
Declaration
public override int GetHashCode()
Returns
Type | Description |
---|---|
Int32 | A hash code formed from the bitwise XOR of this objects members. |
Overrides
Invert()
Inverts this Quaterniond.
Declaration
public void Invert()
Invert(Quaterniond)
Get the inverse of the given Quaterniond
Declaration
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(ref Quaterniond, out Quaterniond)
Get the inverse of the given Quaterniond
Declaration
public static void Invert(ref 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 Quaterniond Inverted()
Returns
Type | Description |
---|---|
Quaterniond |
Multiply(Quaterniond, Quaterniond)
Multiplies two instances.
Declaration
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
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(ref Quaterniond, ref Quaterniond, out Quaterniond)
Multiplies two instances.
Declaration
public static void Multiply(ref Quaterniond left, ref 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(ref Quaterniond, Double, out Quaterniond)
Multiplies an instance by a scalar.
Declaration
public static void Multiply(ref 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
public static Quaterniond Normalize(Quaterniond q)
Parameters
Type | Name | Description |
---|---|---|
Quaterniond | q | The Quaterniond to normalize |
Returns
Type | Description |
---|---|
Quaterniond | The normalized Quaterniond |
Normalize(ref Quaterniond, out Quaterniond)
Scale the given Quaterniond to unit length
Declaration
public static void Normalize(ref 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 Quaterniond Normalized()
Returns
Type | Description |
---|---|
Quaterniond |
Slerp(Quaterniond, Quaterniond, Double)
Do Spherical linear interpolation between two quaternions
Declaration
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
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(ref Quaterniond, ref Quaterniond, out Quaterniond)
Subtracts two instances.
Declaration
public static void Sub(ref Quaterniond left, ref 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 |
ToString()
Returns a System.String that represents the current Quaterniond.
Declaration
public override string ToString()
Returns
Type | Description |
---|---|
String |
Overrides
Operators
Addition(Quaterniond, Quaterniond)
Adds two instances.
Declaration
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. |
Equality(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 |
---|---|
Boolean | True, if left equals right; false otherwise. |
Inequality(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 |
---|---|
Boolean | True, if left does not equal right; false otherwise. |
Multiply(Quaterniond, Quaterniond)
Multiplies two instances.
Declaration
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. |
Multiply(Quaterniond, Double)
Multiplies an instance by a scalar.
Declaration
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. |
Multiply(Double, Quaterniond)
Multiplies an instance by a scalar.
Declaration
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. |
Subtraction(Quaterniond, Quaterniond)
Subtracts two instances.
Declaration
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. |