FastMathAbout FastMath Units Class Hierarchy Classes, Interfaces, Objects and Records Types Variables Constants Functions and Procedures Identifiers License |
record TQuaternion
Unit
Neslib.FastMath
Declaration
type TQuaternion = record
Description
A quaternion.
TQuaternion is compatible with TQuaternion3D in the Delphi RTL. You can typecast between these two types or implicitly convert from one to the other through assignment (eg. MyQuaternion := MyQuaternion3D).
Overview
Fields
X: Single |
Y: Single |
Z: Single |
W: Single |
C: array [0..3] of Single |
Methods
Properties
Description
Fields
C: array [0..3] of Single |
The four components of the quaternion.
|
Methods
procedure Init; overload; inline; |
Initializes the quaternion to an identity quaternion. Sets the X, Y and Z components to 0 and the W component to 1.
|
procedure Init(const AX, AY, AZ, AW: Single); overload; inline; |
Sets the four components of the quaternion.
Parameters
- AX
- the X-component.
- AY
- the Y-component.
- AZ
- the Z-component.
- AW
- the W-component.
|
procedure Init(const AAxis: TVector3; const AAngleRadians: Single); overload; |
Sets the quaternion from the given axis vector and the angle around that axis in radians.
Parameters
- AAxis
- The axis.
- AAngleRadians
- The angle in radians.
|
procedure Init(const AYaw, APitch, ARoll: Single); overload; |
Sets the quaternion to the given euler angles in radians.
Parameters
- AYaw
- the rotation around the Y axis in radians.
- APitch
- the rotation around the X axis in radians.
- ARoll
- the rotation around the Z axis in radians.
|
procedure Init(const AMatrix: TMatrix4); overload; |
Sets the quaternion from a matrix.
Parameters
- AMatrix
- the matrix.
|
function ToMatrix: TMatrix4; |
Creates a rotation matrix that represents this quaternion.
Returns
A rotation matrix that represents this quaternion. |
class operator Implicit(const A: TQuaternion3D): TQuaternion; inline; |
Implicitly converts a TQuaternion3D to a TQuaternion.
|
class operator Implicit(const A: TQuaternion): TQuaternion3D; inline; |
Implicitly converts a TQuaternion to a TQuaternion3D.
|
class operator Multiply(const A: TQuaternion; const B: Single): TQuaternion; |
Multiplies a vector with a scalar value.
Returns
(A.X * B, A.Y * B, A.Z * B, A.W * B) |
class operator Multiply(const A: Single; const B: TQuaternion): TQuaternion; |
Multiplies a vector with a scalar value.
Returns
(A * B.X, A * B.Y, A * B.Z, A * B.W) |
function IsIdentity: Boolean; overload; inline; |
Whether this is an identity quaternion.
Returns
True if X, Y and Z are exactly 0.0 and W is exactly 1.0 |
function IsIdentity(const AErrorMargin: Single): Boolean; overload; |
Whether this is an identity quaternion within a given margin of error.
Parameters
- AErrorMargin
- the allowed margin of error.
Returns
True if this is an identity quaternion within the error margin. |
procedure SetNormalized; inline; |
Normalizes this quaternion to a length of 1.
Note: The SIMD optimized versions of this method use an approximation, resulting in a very small error.
Note: If you do not want to change this quaternion, but get a normalized version instead, then use Normalize.
|
procedure SetNormalizedFast; |
Normalizes this quaternion to a length of 1.
Note: this is an SIMD optimized version that uses an approximation, resulting in a small error. For an accurate version, use SetNormalized.
Note: If you do not want to change this quaternion, but get a normalized version instead, then use NormalizeFast.
|
function Conjugate: TQuaternion; |
Creates a conjugate of the quaternion.
Note: Does not change this quaterion. To update this quaterion itself, use SetConjugate.
Returns
The conjugate (eg. (-X, -Y, -Z, W)) |
Properties
property Length: Single read GetLength; |
The euclidean length of this quaternion.
Note: If you only want to compare lengths of quaternion, you should use LengthSquared instead, which is faster.
|
property LengthSquared: Single read GetLengthSquared; |
The squared length of the quaternion.
Note: This property is faster than Length because it avoids calculating a square root. It is useful for comparing lengths instead of calculating actual lengths.
|
Generated by PasDocEx, based on PasDoc 0.14.0.
|