Castle Game Engine: CastleQuaternions: Object TQuaternion

# Object TQuaternion
Description | Hierarchy | Fields | Methods | Properties
## Unit CastleQuaternions ## Declaration `type TQuaternion = object(TObject)` ## Description ## Hierarchy TObject TQuaternion ## Overview ### Fields
| `Data: packed`
### Methods
| `procedure ToAxisAngle(out Axis: TVector3Single; out AngleRad: Single);`
| `function ToAxisAngle: TVector4Single;`
| `function ToRotationMatrix: TMatrix4Single;`
| `function Rotate(const Point: TVector4Single): TVector4Single; overload;`
| `function Rotate(const Point: TVector3Single): TVector3Single; overload;`
| `function Conjugate: TQuaternion;`
| `procedure ConjugateMe;`
| `procedure Normalize;`
| `procedure LazyNormalize;`
## Description ### Fields
| `Data: packed`
### Methods
| `procedure ToAxisAngle(out Axis: TVector3Single; out AngleRad: Single);`
Calculate axis (will be normalized) and angle (will be in radians) of rotation encoded in unit quaternion Q. This is the reverse of QuatFromAxisAngle.
| `function ToAxisAngle: TVector4Single;`
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.
| `function ToRotationMatrix: TMatrix4Single;`
Calculate matrix doing rotation described by unit quaternion.
| `function Rotate(const Point: TVector4Single): TVector4Single; overload;`
Rotate by unit quaternion. You can pass here TVector4Single, which is then understood to be a 3D position in homogeneous coordinates.
| `function Rotate(const Point: TVector3Single): TVector3Single; overload;`
| `function Conjugate: TQuaternion;`
Quaternion conjugation. This is just a fancy name for negating Q.Vector.
| `procedure ConjugateMe;`
| `procedure Normalize;`
| `procedure LazyNormalize;`
Perform normalization, only if the quaternion is detected to be "significantly unnormalized". It checks if the quaternion needs normalization using fast VectorLenSqr, that is quaternion length is not needed for the check (sqrt not needed). Only if it's significantly different that 1.0, sqrt is done and quaternion is normalized. This may be useful if you fear of eventual errors because of floating-point error cumulations, e.g. when you repeatedly multiply one quaternion by another, and yet another, and yet another etc. Calling this will trigger normalization from time to time (although will tolerate very small, epsilon-like, differences that are normal). Thus it prevents the quaternion from getting "too unnormalized". Generally, this is not needed, as quaternions are nicely numerically stable (which means that quaternion "very slightly unnormalized" will only generate "very slightly wrong" results, so it's not that bad). And no, I didn't actually observe the need for this in my programs. But you can see it actually called when you use TMatrixExaminer and deliberately cause spinning by very very large value (e.g. run view3dscene and press and hold right key, this will cause model spinning very fast, which causes quat multiplication every frame). So possibly this would trigger incorrect quaternions at some point. Anyway, this remains mostly a paranoid correctness measure.
Generated by PasDoc 0.13.0 on 2015-06-15 04:43:11