Unit CastleQuaternions
Description
Quaternions (in particular using them to express 3D rotations).
Uses
Overview
Classes, Interfaces, Objects and Records
Name | Description |
---|---|
Record TQuaternion |
Quaternions are useful to represent rotations in 3D that can be easily applied and combined with other rotations. |
Functions and Procedures
function QuatFromAxisAngle(const Axis: TVector3; const AngleRad: Single; const NormalizeAxis: boolean = false): TQuaternion; overload; |
function QuatFromAxisAngle(const AxisAngle: TVector4; const NormalizeAxis: boolean = false): TQuaternion; overload; |
function QuatFromRotationMatrix(const Matrix: TMatrix3): TQuaternion; |
procedure MatrixDecompose(const Matrix: TMatrix4; out Translation: TVector3; out Rotation: TVector4; out Scale: TVector3); |
function SLerp(const A: Single; const Q1, Q2: TQuaternion): TQuaternion; overload; |
function SLerp(const A: Single; const Rot1, Rot2: TVector4): TVector4; overload; |
function NLerp(const A: Single; const Q1, Q2: TQuaternion; const ForceShortestPath: boolean = true): TQuaternion; overload; |
function NLerp(const A: Single; const Rot1, Rot2: TVector4; const ForceShortestPath: boolean = true): TVector4; overload; |
Constants
QuatIdentityRot: TQuaternion = (Data: (Vector: (Data: (0, 0, 0)); Real: 1))
deprecated 'use TQuaternion.ZeroRotation'; |
Description
Functions and Procedures
function QuatFromAxisAngle(const Axis: TVector3; const AngleRad: Single; const NormalizeAxis: boolean = false): TQuaternion; overload; |
Calculate unit quaternion representing rotation around Axis by AngleRad angle (in radians). Axis must be normalized, or you have to pass NormalizeAxis = true (then we'll normalize it ourselves inside). Otherwise you will get non-normalized quaternion that doesn't represent rotation, and is usually useless for us. |
function QuatFromAxisAngle(const AxisAngle: TVector4; const NormalizeAxis: boolean = false): TQuaternion; overload; |
function QuatFromRotationMatrix(const Matrix: TMatrix3): TQuaternion; |
Initialize rotation quaternion from a 3x3 matrix that contains only rotation. |
procedure MatrixDecompose(const Matrix: TMatrix4; out Translation: TVector3; out Rotation: TVector4; out Scale: TVector3); |
Decompose a matrix that is composition of 3D translation, rotation and scale. The returned Rotation is expressed as an axis-angle (first 3 components are axis, last component is an angle in radians), as usual in our engine (see e.g. TCastleTransform.Rotation). |
function SLerp(const A: Single; const Q1, Q2: TQuaternion): TQuaternion; overload; |
Interpolate between two rotations, along the shortest path on the unit sphere, with constant speed. The overloaded version that works with TVector4 takes a rotation (not a quaternion) expressed as an axis (first 3 elements) and angle (in radians, 4th element). Axis does not have to be normalized (we'll normalize it). This is nice e.g. to interpolate VRML/X3D rotations. |
function SLerp(const A: Single; const Rot1, Rot2: TVector4): TVector4; overload; |
function NLerp(const A: Single; const Q1, Q2: TQuaternion; const ForceShortestPath: boolean = true): TQuaternion; overload; |
Interpolate between two rotations, along the straightest path on the unit sphere. This is faster than SLerp, but does not guarantee the interpolated result travels with constant speed. Often it's not a noticeable / important problem (see http://number-none.com/product/Understanding%20Slerp,%20Then%20Not%20Using%20It/) When ForceShortestPath = The overloaded version that works with TVector4 takes a rotation (not a quaternion) expressed as an axis (first 3 elements) and angle (in radians, 4th element). Axis does not have to be normalized (we'll normalize it). This is nice e.g. to interpolate VRML/X3D rotations. |
function NLerp(const A: Single; const Rot1, Rot2: TVector4; const ForceShortestPath: boolean = true): TVector4; overload; |
Constants
QuatIdentityRot: TQuaternion = (Data: (Vector: (Data: (0, 0, 0)); Real: 1))
deprecated 'use TQuaternion.ZeroRotation'; |
Warning: this symbol is deprecated: use TQuaternion.ZeroRotation |
Generated by PasDoc 0.16.0.