Packing Slua rotations into vector-sized object would greatly reduce garbage creation.
Janet Rossini
SL rotations are unit rotations. As such, they can readily be stored in a vector, dropping the s field, and reconstructing it as needed. Non-physical vehicles, such as trains, create multiple rotations per second, as do many other dynamic objects. A polymorphic vector-sized rotation could fit in the Slua stack, as do vectors. If accepted, for example, in ll.SetLinkPrimitiveParamsFast, these vector-sized rotations would reduce garbage creation substantially. Since the math would be done inside C++, reconstituting the s field would quite likely be a very reasonable trade off.
Log In
Journey Bunny
Quaternions aren't guaranteed to be normalized--llAxes2Rot is not, and any mathematics we do ourselves are not necessarily.
Things that would have to be addressed with the proposed dropping:
The sign of s matters, and reconstruction can only produce |s|, so the procedure would require forcing s into > 0 (negating other components as needed) in order to get the correct orientation. Otherwise, we'd lose the sign and return the
wrong
rotation in all cases where s was originally negative.The reconstuction is then s = sqrt(1-x^2-y^2-z^2) and precision drops as we near 180 dedgrees rotation. Accuracy loss is is amplified by the square root op by 1/(2s). Error scales, so a 90 degree rotation amplifies 32-bit rounding errors by ~0.7x; 180 degree rotation amplifies the precision error by 3200x. As 180 is the largest rotation, that is the maximum error at about 0.4 degrees. It's not a large error, but it is exponential, which is a change from the 4-component form.
Perfectly axis-aligned rotations
should
be exact; non axis-aligned rotations produce this error, which could be negative, so the reconstruction function would need to accound for possible sqrt(-N).