Struct QuaternionD
Represents a QuaternionD (single precision).
Implements
Inherited Members
Namespace: Fusee.Math.Core
Assembly: Fusee.Math.Core.dll
Syntax
public struct QuaternionD : IEquatable<QuaternionD>
  Constructors
QuaternionD(double3, Double)
Construct a new QuaternionD from vector and w components
Declaration
public QuaternionD(double3 v, double w)
  Parameters
| Type | Name | Description | 
|---|---|---|
| double3 | v | The vector part  | 
      
| System.Double | w | The w part  | 
      
QuaternionD(Double, Double, Double, Double)
Construct a new QuaternionD
Declaration
public QuaternionD(double xx, double yy, double zz, double w)
  Parameters
| Type | Name | Description | 
|---|---|---|
| System.Double | xx | The xx component  | 
      
| System.Double | yy | The yy component  | 
      
| System.Double | zz | The zz component  | 
      
| System.Double | w | The w component  | 
      
Fields
Identity
Defines the identity quaternion.
Declaration
public static readonly QuaternionD Identity
  Field Value
| Type | Description | 
|---|---|
| QuaternionD | 
Properties
Item[Int32]
Sets/Gets value from given idx
Declaration
public double this[int idx] { get; set; }
  Parameters
| Type | Name | Description | 
|---|---|---|
| System.Int32 | idx | 
Property Value
| Type | Description | 
|---|---|
| System.Double | 
Length
Gets the length (magnitude) of the quaternion.
Declaration
public readonly double Length { get; }
  Property Value
| Type | Description | 
|---|---|
| System.Double | 
See Also
LengthSquared
Gets the square of the quaternion length (magnitude).
Declaration
public readonly double LengthSquared { get; }
  Property Value
| Type | Description | 
|---|---|
| System.Double | 
w
Gets and sets the w component of this instance.
Declaration
public double w { get; set; }
  Property Value
| Type | Description | 
|---|---|
| System.Double | 
x
Gets and sets the x component of this instance.
Declaration
public double x { get; set; }
  Property Value
| Type | Description | 
|---|---|
| System.Double | 
xyz
Gets and sets an Fusee.Math.double3 with the x, y and z components of this instance.
Declaration
public double3 xyz { get; set; }
  Property Value
| Type | Description | 
|---|---|
| double3 | 
y
Gets and sets the y component of this instance.
Declaration
public double y { get; set; }
  Property Value
| Type | Description | 
|---|---|
| System.Double | 
z
Gets and sets the z component of this instance.
Declaration
public double z { get; set; }
  Property Value
| Type | Description | 
|---|---|
| System.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  | 
      
Conjugate()
Convert this quaternion to its conjugate.
Declaration
public QuaternionD Conjugate()
  Returns
| Type | Description | 
|---|---|
| QuaternionD | 
Conjugate(QuaternionD)
Get the conjugate of the given quaternion
Declaration
public static QuaternionD Conjugate(QuaternionD q)
  Parameters
| Type | Name | Description | 
|---|---|---|
| QuaternionD | q | The quaternion  | 
      
Returns
| Type | Description | 
|---|---|
| QuaternionD | The conjugate of the given quaternion  | 
      
CopySign(Double, Double)
a with the algebraic sign of b.
Declaration
public static double CopySign(double a, double b)
  Parameters
| Type | Name | Description | 
|---|---|---|
| System.Double | a | Absolut value  | 
      
| System.Double | b | A positiv/negativ number or zero.  | 
      
Returns
| Type | Description | 
|---|---|
| System.Double | Returns a with the algebraic sign of b.  | 
      
Remarks
Takes a as an absolute value and multiplies it with: +1 for any positiv number for b, -1 for any negative number for b or 0 for 0 for b.
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 | 
|---|---|
| System.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 | 
|---|---|---|
| System.Object | other | The other object to be used in the comparison.  | 
      
Returns
| Type | Description | 
|---|---|
| System.Boolean | True if both objects are QuaternionDs of equal value. Otherwise it returns false.  | 
      
Overrides
FromAxisAngle(double3, Double)
Build a quaternion from the given axis and angle
Declaration
public static QuaternionD FromAxisAngle(double3 axis, double angle)
  Parameters
| Type | Name | Description | 
|---|---|---|
| double3 | axis | The axis to rotate about  | 
      
| System.Double | angle | The rotation angle in radians  | 
      
Returns
| Type | Description | 
|---|---|
| QuaternionD | A normalized quaternion rotation.  | 
      
FromEuler(double3, Boolean)
Convert Euler angle to Quaternion rotation.
Declaration
public static QuaternionD FromEuler(double3 e, bool inDegrees = false)
  Parameters
| Type | Name | Description | 
|---|---|---|
| double3 | e | Euler angle to convert.  | 
      
| System.Boolean | inDegrees | Whether the angles are in degrees or radians.  | 
      
Returns
| Type | Description | 
|---|---|
| QuaternionD | A Quaternion representing the euler angle passed to this method.  | 
      
Remarks
The euler angle is assumed to be in common aviation order where the y axis is up. Thus x is pitch/attitude, y is yaw/heading, and z is roll/bank. In practice x is never out of [-PI/2, PI/2] while y and z may well be in the range of [-PI, PI].
See also the euclideanspace website.
FromEuler(Double, Double, Double, Boolean)
Convert Euler angle to Quaternion rotation.
Declaration
public static QuaternionD FromEuler(double x, double y, double z, bool inDegrees = false)
  Parameters
| Type | Name | Description | 
|---|---|---|
| System.Double | x | Angle around x.  | 
      
| System.Double | y | Angle around x.  | 
      
| System.Double | z | Angle around x.  | 
      
| System.Boolean | inDegrees | Whether the angles are in degrees or radians.  | 
      
Returns
| Type | Description | 
|---|---|
| QuaternionD | A Quaternion representing the euler angle passed to this method.  | 
      
Remarks
The euler angle is assumed to be in common aviation order where the y axis is up. Thus x is pitch/attitude, y is yaw/heading, and z is roll/bank. In practice x is never out of [-PI/2, PI/2] while y and z may well be in the range of [-PI, PI].
See also the euclideanspace website.
FromRotationMatrix(double4x4)
Build a quaternion from a rotation matrix
Declaration
public static QuaternionD FromRotationMatrix(double4x4 mtx)
  Parameters
| Type | Name | Description | 
|---|---|---|
| double4x4 | mtx | 
Returns
| Type | Description | 
|---|---|
| QuaternionD | 
FromToRotation(double3, double3)
Build a quaternion with the shortest rotation from to.
Declaration
public static QuaternionD FromToRotation(double3 from, double3 to)
  Parameters
| Type | Name | Description | 
|---|---|---|
| double3 | from | |
| double3 | to | 
Returns
| Type | Description | 
|---|---|
| QuaternionD | A normalized quaternion rotation.  | 
      
GetHashCode()
Provides the hash code for this object.
Declaration
public override int GetHashCode()
  Returns
| Type | Description | 
|---|---|
| System.Int32 | A hash code formed from the bitwise XOR of this objects members.  | 
      
Overrides
Invert()
Convert this quaternion to its inverse.
Declaration
public QuaternionD Invert()
  Returns
| Type | Description | 
|---|---|
| QuaternionD | 
Invert(QuaternionD)
Get the inverse of the given quaternion
Declaration
public static QuaternionD Invert(QuaternionD q)
  Parameters
| Type | Name | Description | 
|---|---|---|
| QuaternionD | q | The quaternion to invert  | 
      
Returns
| Type | Description | 
|---|---|
| QuaternionD | The inverse of the given quaternion  | 
      
LookRotation(double3, double3)
Takes a lookAt and upDirection vector and returns a quaternion rotation.
Declaration
public static QuaternionD LookRotation(double3 lookAt, double3 upDirection)
  Parameters
| Type | Name | Description | 
|---|---|---|
| double3 | lookAt | The look at.  | 
      
| double3 | upDirection | Up direction.  | 
      
Returns
| Type | Description | 
|---|---|
| QuaternionD | A 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.  | 
      
| System.Double | scale | The scalar.  | 
      
Returns
| Type | Description | 
|---|---|
| QuaternionD | A new instance containing the result of the calculation.  | 
      
Normalize()
Scales the QuaternionD to unit length.
Declaration
public QuaternionD Normalize()
  Returns
| Type | Description | 
|---|---|
| QuaternionD | 
Normalize(QuaternionD)
Scale the given quaternion to unit length
Declaration
public static QuaternionD Normalize(QuaternionD q)
  Parameters
| Type | Name | Description | 
|---|---|---|
| QuaternionD | q | The quaternion to normalize  | 
      
Returns
| Type | Description | 
|---|---|
| QuaternionD | The normalized quaternion  | 
      
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 quaternion  | 
      
| QuaternionD | q2 | The second quaternion  | 
      
| System.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.  | 
      
ToAxisAngle()
Convert this instance to an axis-angle representation.
Declaration
public double4 ToAxisAngle()
  Returns
| Type | Description | 
|---|---|
| double4 | A double4 that is the axis-angle representation of this quaternion.  | 
      
ToAxisAngle(QuaternionD)
Angle axis representation of the given quaternion.
Declaration
public static double4 ToAxisAngle(QuaternionD quat)
  Parameters
| Type | Name | Description | 
|---|---|---|
| QuaternionD | quat | The quaternion to transform.  | 
      
Returns
| Type | Description | 
|---|---|
| double4 | 
ToEuler(QuaternionD, Boolean)
Convert QuaternionD rotation to Euler Angles.
Declaration
public static double3 ToEuler(QuaternionD q, bool inDegrees = false)
  Parameters
| Type | Name | Description | 
|---|---|---|
| QuaternionD | q | QuaternionD rotation to convert.  | 
      
| System.Boolean | inDegrees | Whether the angles shall be in degrees or radians.  | 
      
Returns
| Type | Description | 
|---|---|
| double3 | 
Remarks
The euler angle is assumed to be in common aviation order where the y axis is up. Thus x is pitch/attitude, y is yaw/heading, and z is roll/bank. In practice x is never out of [-PI/2, PI/2] while y and z may well be in the range of [-PI, PI].
See also the euclidean space website.
ToRotationMatrix()
Converts the quaternion into a rotation matrix.
Declaration
public double4x4 ToRotationMatrix()
  Returns
| Type | Description | 
|---|---|
| double4x4 | 
ToRotationMatrix(QuaternionD)
Convert QuaternionD to rotation matrix
Declaration
public static double4x4 ToRotationMatrix(QuaternionD q)
  Parameters
| Type | Name | Description | 
|---|---|---|
| QuaternionD | q | QuaternionD to convert.  | 
      
Returns
| Type | Description | 
|---|---|
| double4x4 | A matrix of type double4x4 from the passed QuaternionD.  | 
      
ToRotationMatrixFast()
Converts the quaternion into a rotation matrix.
Declaration
public double4x4 ToRotationMatrixFast()
  Returns
| Type | Description | 
|---|---|
| double4x4 | 
ToRotationMatrixFast(QuaternionD)
Constructs a rotation matrix from a given quaternion This uses some geometric algebra magic https://en.wikipedia.org/wiki/Geometric_algebra From: https://sourceforge.net/p/mjbworld/discussion/122133/thread/c59339da/#62ce
Declaration
public static double4x4 ToRotationMatrixFast(QuaternionD quat)
  Parameters
| Type | Name | Description | 
|---|---|---|
| QuaternionD | quat | Input quaternion  | 
      
Returns
| Type | Description | 
|---|---|
| double4x4 | 
ToString()
Returns a System.String that represents the current QuaternionD.
Declaration
public override string ToString()
  Returns
| Type | Description | 
|---|---|
| System.String | A string.  | 
      
Overrides
ToString(IFormatProvider)
Returns a System.String that represents the current QuaternionD.
Declaration
public string ToString(IFormatProvider provider)
  Parameters
| Type | Name | Description | 
|---|---|---|
| System.IFormatProvider | provider | Provides information about a specific culture.  | 
      
Returns
| Type | Description | 
|---|---|
| System.String | A System.String that represents this instance.  | 
      
Transform(double4, QuaternionD)
Transforms a vector by a quaternion rotation.
Declaration
public static double4 Transform(double4 vec, QuaternionD quat)
  Parameters
| Type | Name | Description | 
|---|---|---|
| double4 | vec | The vector to transform.  | 
      
| QuaternionD | quat | The quaternion to rotate the vector by.  | 
      
Returns
| Type | Description | 
|---|---|
| double4 | The result of the operation.  | 
      
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 | 
|---|---|
| System.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 | 
|---|---|
| System.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.  | 
      
| System.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 | 
|---|---|---|
| System.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.  |