[webkit-dev] TransformationMatrix rotation code and floating-point precision
Shawn Singh
shawnsingh at chromium.org
Mon May 14 19:30:10 PDT 2012
Hi all,
I'm looking at TransformationMatrix::rotate3d(rx, ry, rz). This code does
something indirect, and I don't understand why. Instead of initializing
each rotation using sin(theta), cos(theta), the code computes theta/2, and
then uses trig identities to initialize the rotation matrix.
I checked really quickly with fprintf, and it seems like we could actually
gain 1-2 bits of precision if we avoid doing this, and use sin(theta) and
cos(theta) directly. In the current code, more error seems to accumulate
due to sin^2 (theta / 2). Squaring that value instantly increases the
error inherent in the computation. I cannot think of any valid reason that
this code uses those trig identities instead of directly using sin and cos.
Does anyone else know why? Is this worth changing to gain some precision?
On a secondary note, its also fishy that we are freely mixing floats and
doubles in the rotation code. But, I don't think that is as significant
error accumulation as the sin^2.
Thanks,
~Shawn
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.webkit.org/pipermail/webkit-dev/attachments/20120514/dc39fa4c/attachment.html>
More information about the webkit-dev
mailing list