Castle Game EngineIntroduction Units Class Hierarchy Classes, Interfaces, Objects and Records Types Variables Constants Functions and Procedures Identifiers |
Unit CastleQuaternions
Description
Quaternions (in particular using them to express 3D rotations).
Uses
Overview
Classes, Interfaces, Objects and Records
Functions and Procedures
Constants
Description
Functions and Procedures
function QuatFromAxisAngle(const Axis: TVector3Single; const AngleRad: Single; const NormalizeAxis: boolean = false): TQuaternion; |
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.
|
operator * (const Q1, Q2: TQuaternion): TQuaternion; |
Multiply two quaternions.
Geometric interpretation: If these are unit quaternions representing rotations, multiplying them calculates one rotation that has the same effect as rotating by Q2 and then by Q1.
Normal of result is equal to norm of Q1 * norm of Q2 (in particular, multiplying unit quaternions (used for rotations) yields another unit quaternion for sure).
|
function SLerp(const A: Single; const Q1, Q2: TQuaternion): TQuaternion; |
Interpolate between two rotations, along the shortest path on the unit sphere, with constant speed.
The overloaded version that works with TVector4Single 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 Q1, Q2: TQuaternion; const ForceShortestPath: boolean = true): TQuaternion; |
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 = False , this doesn't guarantee choosing the shortest path. Although it goes through the straightest path, there are two such paths, it may go through the shorter or longer one. Use ForceShortestPath = True if you want to interpolate through the shortest.
The overloaded version that works with TVector4Single 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.
|
Constants
QuatIdentityRot: TQuaternion = (Data: (Vector: (0, 0, 0); Real: 1)); |
|
Generated by PasDoc 0.13.0 on 2014-10-26 05:15:14
|