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.
|