Quaternion Type
A struct containing 4 floats, representing an immutable unitized Quaternion, for arbitrary 3D rotations. This implementation guarantees the Quaternion to be always unitized. Note: Never use the struct default constructor Quaternion() as it will create an invalid zero length Quaternion. Use Quaternion.create or Quaternion.createUnchecked instead.
Record fields
| Record Field |
Description
|
Full Usage:
W
Field type: float
|
The field holding the W component of this Quaternion.
|
Full Usage:
X
Field type: float
|
The field holding the X component of this Quaternion.
|
Full Usage:
Y
Field type: float
|
The field holding the Y component of this Quaternion.
|
Full Usage:
Z
Field type: float
|
The field holding the Z component of this Quaternion.
|
Instance members
| Instance member |
Description
|
Full Usage:
this.AngleInDegrees
Returns: float
Modifiers: inline |
Returns the angle in Degree.
|
Full Usage:
this.AngleInRadians
Returns: float
Modifiers: inline |
Returns the angle in Radians.
|
Full Usage:
this.AsFSharpCode
Returns: string
|
Format Quaternion into an F# code string that can be used to recreate the quaternion.
|
Full Usage:
this.AsString
Returns: string
|
Format Quaternion into string also showing angle in Degree as nicely formatted floating point number. Using nice floating point number formatting. But without full type name as in q.ToString()
|
Returns the rotation axis of this Quaternion as a (non-unit) vector. This is just q.X, q.Y and q.Z, which equals axis * sin(angle/2). For the identity quaternion (no rotation), this returns a zero-length vector Vec(0,0,0). The length of this vector is sin(angle/2), ranging from 0 (no rotation) to 1 (180° rotation).
|
|
|
Returns a new Quaternion for the inverse rotation. Same as q.Inverse.
|
|
Returns a new Quaternion for the inverse rotation. Same as q.Conjugate.
|
|
This method should normally not be needed as Euclid Quaternions are always unitized. However, use this to correct numerical drift after many quaternion multiplications. This is the same as calling Quaternion.create with the current components. Returns a renormalized copy of this Quaternion with unit length.
|
Full Usage:
this.setAngleInDegrees angleInDegrees
Parameters:
float
Returns: Quaternion
Modifiers: inline |
Get a new Quaternion that rotates around the same axis but with a different angle. In Degree. Fails for identity or near-identity quaternions where the rotation axis is not defined (angle ≈ 0).
|
Full Usage:
this.setAngleInRadians angleInRadians
Parameters:
float
Returns: Quaternion
|
Get a new Quaternion that rotates around the same axis but with a different angle. In Radians. Fails for identity or near-identity quaternions where the rotation axis is not defined (angle ≈ 0).
|
Static members
| Static member |
Description
|
|
Rotate by Quaternion around Origin. Multiplies (or applies) a Quaternion to a 3D point.
|
|
Rotate by Quaternion around Origin. Multiplies (or applies) a Quaternion to a 3D unit-vector.
|
|
Rotate by Quaternion around Origin. Multiplies (or applies) a Quaternion to a 3D vector.
|
|
Multiply two Quaternions. It's like adding one rotation to the other.
|
Full Usage:
Quaternion.create (x, y, z, w)
Parameters:
float
y : float
z : float
w : float
Returns: Quaternion
|
|
Full Usage:
Quaternion.createFromDegree (axis, angleInDegrees)
Parameters:
UnitVec
angleInDegrees : float
Returns: Quaternion
Modifiers: inline |
The created rotation is Clockwise looking in the direction of the unit-vector.
|
Full Usage:
Quaternion.createFromDegree (axis, angleInDegrees)
Parameters:
Vec
angleInDegrees : float
Returns: Quaternion
Modifiers: inline |
The created rotation is Clockwise looking in the direction of the vector (of any length but zero).
|
Full Usage:
Quaternion.createFromEulerXYZ (degreesX, degreesY, degreesZ)
Parameters:
float
degreesY : float
degreesZ : float
Returns: Quaternion
|
Angles are given in Degrees, The order in which to apply rotations is X-Y-Z, which means that the object will first be rotated around its X-axis, then its Y-axis and finally its Z-axis. This uses intrinsic Tait-Bryan angles. This means that rotations are performed with respect to the local coordinate system. That is, for order X-Y-Z, the rotation is first around the local-X-axis (which is the same as the World-X-axis), then around local-Y (which may now be different from the World Y-axis), then local-Z (which may be different from the World Z-axis)
|
Full Usage:
Quaternion.createFromEulerXZY (degreesX, degreesZ, degreesY)
Parameters:
float
degreesZ : float
degreesY : float
Returns: Quaternion
|
Angles are given in Degrees, The order in which to apply rotations is X-Z-Y, which means that the object will first be rotated around its X-axis, then its Z-axis and finally its Y-axis. This uses intrinsic Tait-Bryan angles. This means that rotations are performed with respect to the local coordinate system. That is, for order X-Z-Y, the rotation is first around the local-X-axis (which is the same as the World-X-axis), then around local-Z (which may now be different from the World Z-axis), then local-Y (which may be different from the World Y-axis)
|
Full Usage:
Quaternion.createFromEulerYXZ (degreesY, degreesX, degreesZ)
Parameters:
float
degreesX : float
degreesZ : float
Returns: Quaternion
|
Angles are given in Degrees, The order in which to apply rotations is Y-X-Z, which means that the object will first be rotated around its Y-axis, then its X-axis and finally its Z-axis. This uses intrinsic Tait-Bryan angles. This means that rotations are performed with respect to the local coordinate system. That is, for order Y-X-Z, the rotation is first around the local-Y-axis (which is the same as the World-Y-axis), then around local-X (which may now be different from the World X-axis), then local-Z (which may be different from the World Z-axis)
|
Full Usage:
Quaternion.createFromEulerYZX (degreesY, degreesZ, degreesX)
Parameters:
float
degreesZ : float
degreesX : float
Returns: Quaternion
|
Angles are given in Degrees, The order in which to apply rotations is Y-Z-X, which means that the object will first be rotated around its Y-axis, then its Z-axis and finally its X-axis. This uses intrinsic Tait-Bryan angles. This means that rotations are performed with respect to the local coordinate system. That is, for order Y-Z-X, the rotation is first around the local-Y-axis (which is the same as the World-Y-axis), then around local-Z (which may now be different from the World Z-axis), then local-X (which may be different from the World X-axis)
|
Full Usage:
Quaternion.createFromEulerZXY (degreesZ, degreesX, degreesY)
Parameters:
float
degreesX : float
degreesY : float
Returns: Quaternion
|
Angles are given in Degrees, The order in which to apply rotations is Z-X-Y, which means that the object will first be rotated around its Z-axis, then its X-axis finally its Y-axis. This uses intrinsic Tait-Bryan angles. This means that rotations are performed with respect to the local coordinate system. That is, for order Z-X-Y, the rotation is first around the local-Z-axis (which is the same as the World-Z-axis), then around local-X (which may now be different from the World X-axis), then local-Y (which may be different from the World Y-axis)
|
Full Usage:
Quaternion.createFromEulerZYX (degreesZ, degreesY, degreesX)
Parameters:
float
degreesY : float
degreesX : float
Returns: Quaternion
|
Angles are given in Degrees, The order in which to apply rotations is Z-Y-X, which means that the object will first be rotated around its Z-axis, then its Y-axis and finally its X-axis. This uses intrinsic Tait-Bryan angles. This means that rotations are performed with respect to the local coordinate system. That is, for order Z-Y-X, the rotation is first around the local Z-axis (which is the same as the World Z-axis), then around local-Y (which may now be different from the World Y-axis), then local-X (which may be different from the World X-axis)
|
Full Usage:
Quaternion.createFromRadians (axis, angleInRadians)
Parameters:
UnitVec
angleInRadians : float
Returns: Quaternion
Modifiers: inline |
The created rotation is Clockwise looking in the direction of the unit-vector.
|
Full Usage:
Quaternion.createFromRadians (axis, angleInRadians)
Parameters:
Vec
angleInRadians : float
Returns: Quaternion
|
The created rotation is Clockwise looking in the direction of the vector. The vector may be of any length but zero.
|
Full Usage:
Quaternion.createUnchecked (x, y, z, w)
Parameters:
float
y : float
z : float
w : float
Returns: Quaternion
Modifiers: inline |
This unsafe constructor does NOT do any unitizing.
|
|
Creates a rotation from one vector's direction to another vector's direction. If the tips of the two vectors (unitized) are closer than 1e-12 (squared: 1e-24) then an identity Quaternion is returned. If the tips of the two vectors (unitized) are almost exactly opposite (sum length too small), there is no valid unique 180 degree rotation that can be found, so an exception is raised.
|
Full Usage:
Quaternion.createVecToVec (vecFrom, vecTo)
Parameters: Returns: Quaternion
Modifiers: inline |
Creates a rotation from one vector's direction to another vector's direction. If the tips of the two unit vectors are closer than 1e-12 (squared: 1e-24) then an identity Quaternion is returned. If the tips of the two vectors are almost exactly opposite (sum length too small), there is no valid unique 180 degree rotation that can be found, so an exception is raised.
|
Full Usage:
Quaternion.equals tolerance a b
Parameters:
float
a : Quaternion
b : Quaternion
Returns: bool
Modifiers: inline |
Checks if two Quaternion are equal within tolerance (component-wise comparison). Use a tolerance of 0.0 to check for an exact match. Note: A Quaternion with every component negated represents the same rotation but will be considered unequal by this function. For rotational equivalence, consider using Quaternion.equalsRotation function.
|
Full Usage:
Quaternion.equalsRotation tolerance a b
Parameters:
float
a : Quaternion
b : Quaternion
Returns: bool
Modifiers: inline |
Checks if two Quaternion represent an equal rotation. Use a tolerance of 0.0 to check for an exact match. Note: A Quaternion with every component negated represents the same rotation and will be considered equal by this function. For component-wise equality, consider using Quaternion.equals function.
|
|
The identity quaternion that does not do any rotation. This is Quaternion(x=0, y=0, z=0, w=1)
|
Full Usage:
Quaternion.multiply (l, r)
Parameters:
Quaternion
r : Quaternion
Returns: Quaternion
|
Multiply two Quaternions. It's like adding one rotation to the other. Note: Repeated multiplications may accumulate floating-point errors that violate the unit-length invariant. Use q.Normalize() to renormalize if combining many rotations.
|
|
The quaternion expresses a relationship between two coordinate frames, A and B say. Returns the EulerAngles in Degrees: Alpha, Beta, Gamma. This relationship, if expressed using Euler angles, is as follows: 1) Rotate Frame A about its Z-axis by angle Gamma; 2) Rotate the resulting frame about its (new) Y-axis by angle Beta; 3) Rotate the resulting frame about its (new) X-axis by angle Alpha, to arrive at frame B. Returns the angles in Degrees as triple. For rotating first around the axis Z then local Y and finally local X. Note: This conversion may encounter gimbal lock issues when Beta is near ±90°. see Quaternion.createFromEulerZYX(z, y, x)
|
Euclid