[webkit-dev] TransformationMatrix rotation code and floating-point precision

Ryosuke Niwa rniwa at webkit.org
Mon May 14 22:52:16 PDT 2012


I don't know anything about transformation matrix, but that sounds like a
pretty simple change. I would just upload a patch to make this change on
bugs.webkit.org if I were you, and cc relevant people (use
trac.webkit.orgto see who has authored/reviewed patches in the
relevant files).

- Ryosuke

On Mon, May 14, 2012 at 7:30 PM, Shawn Singh <shawnsingh at chromium.org>wrote:
>
> 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
>
> _______________________________________________
> webkit-dev mailing list
> webkit-dev at lists.webkit.org
> http://lists.webkit.org/mailman/listinfo.cgi/webkit-dev
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.webkit.org/pipermail/webkit-dev/attachments/20120514/16fc5502/attachment.html>


More information about the webkit-dev mailing list