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 Quaternion(const V: TVector4): TQuaternion;
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;
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: (X: 0; Y: 0; Z: 0); Real: 1)) deprecated 'use TQuaternion.ZeroRotation';

Description

Functions and Procedures

function Quaternion(const V: TVector4): TQuaternion;

Quaternion with given vector. See TQuaternion and SLerp for useful things you can do with quaternions. See QuatFromAxisAngle if instead you want to initialize quternion with axis+angle vector.

See also
QuatFromAxisAngle
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;

This item has no description.

function QuatFromRotationMatrix(const Matrix: TMatrix3): TQuaternion;

Initialize rotation quaternion from a 3x3 matrix that contains only 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;

This item has no description.

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 = 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 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;

This item has no description.

Constants

QuatIdentityRot: TQuaternion = (Data: (Vector: (X: 0; Y: 0; Z: 0); Real: 1)) deprecated 'use TQuaternion.ZeroRotation';

Warning: this symbol is deprecated: use TQuaternion.ZeroRotation

This item has no description.


Generated by PasDoc 0.16.0-snapshot.