Gorilla.Utils.Quaternions
Unit Gorilla.Utils.Quaternions.pasRecords
- record TQuaternion
Constants
- const QuatIdentityRot : TQuaternion = ;
Functions / Procedures
- public function QuatFromAxisAngle
(
const
Axis :
TPoint3D; 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.
- public function QuatFromAxisAngle
(
const
AxisAngle :
TVector3D; 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.
- public function SLerp
(
const
A :
Single; const
Q1 :
TQuaternion; const
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 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.
- public function SLerp
(
const
A :
Single; const
Rot1 :
TVector3D; const
Rot2 :
TVector3D
)
: TVector3D
;
overload;
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.
- public function NLerp
(
const
A :
Single; const
Q1 :
TQuaternion; const
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 @italic(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.
- public function NLerp
(
const
A :
Single; const
Rot1 :
TVector3D; const
Rot2 :
TVector3D; const
ForceShortestPath :
Boolean
=
True
)
: TVector3D
;
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 @italic(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.
TQuaternion
Fields
Methods
- public constructor Create
(
const
X :
Single; const
Y :
Single; const
Z :
Single; const
W :
Single
=
1
)
;
public constructor Create ( const AVector : TVector3D ) ;
Sets the quaternion values from x,y,z and a w value.
public constructor Create ( const APoint : TPoint3D; const W : Single = 1 ) ;Sets the quaternion values by the submitted 4 value vector.
public constructor Create ( const AMatrix : TMatrix3D ) ;Sets the quaternion values from a 3 value vector and a w value.
public constructor Create ( const AMatrix : TMatrix ) ;Sets the quaternion values from a 4x4 matrix. The method will extract the rotation matrix and then computed axis and rotations.
public constructor CreateFromEuler ( const AAngles : TPoint3D ) ;Sets the quaternion values from a 3x3 rotation matrix. The method will compute axis and rotations from that matrix.
Sets the quaternion values from euler angles (in radians).
- public function Identity
(
)
: TQuaternion
;
static;
Returns an identity quaternion vector4f(0, 0, 0, 1).
- public function NormalizeTo
(
)
: TQuaternion
;
Normalizes this quaternion and returns a new quaternion. The source quaternion will not be affected.
- public function Length
(
)
: Single
;
Returns the length of containing vector3f and real-part.
- public procedure ToAxisAngle
(
out
Axis :
TPoint3D; out
AngleRad :
Single
)
;
overload;
Calculate axis (will be normalized) and angle (will be in radians) of rotation encoded in unit quaternion Q. This is the reverse of QuatFromAxisAngle.
- public function ToAxisAngle
(
)
: TVector3D
;
overload;
Convert quaternion to a rotation axis and angle encoded in 4D vector. Axis is normalized if quaternion was also normalized (which is true if working with rotation quaternions). Angle is in radians.
- public function ToEulerAngles
(
)
: TPoint3D
;
Computes and returns the euler angles of this quaternion. The result is already converted from radians to degrees.
- public function ToVector3D
(
)
: TVector3D
;
Converts the quaternion to a vector with 4 values.
- public function ToQuaternion3D
(
)
: TQuaternion3D
;
Converts the Gorilla quaternion to a delphi firemonkey TQuaternion3D.
- public function ToRotationMatrix3D
(
)
: TMatrix3D
;
Calculate matrix doing rotation described by unit quaternion.
- public function ToRotationMatrix
(
)
: TMatrix
;
Calculate matrix doing rotation described by unit quaternion.
- public function Rotate
(
const
Point :
TVector3D
)
: TVector3D
;
overload;
Rotate by unit quaternion. You can pass here TVector4Single, which is then understood to be a 3D position in homogeneous coordinates.
- public function Rotate
(
const
Point :
TPoint3D
)
: TPoint3D
;
overload;
Rotate by unit quaternion. You can pass here TVector4Single, which is then understood to be a 3D position in homogeneous coordinates.
- public function Conjugate
(
)
: TQuaternion
;
Quaternion conjugation. This is just a fancy name for negating Q.Vector.
- public procedure ConjugateMe
(
)
;
Quaternion conjugation. This is just a fancy name for negating Q.Vector.
- public procedure Normalize
(
)
;
Normalizes the vector part of the quaternion value.
- public function operator Multiply ( const Q1 : TQuaternion; const Q2 : TQuaternion ) : TQuaternion ; class noself operator overload;