[cairo-bugs] [Bug 89071] New: cairo_rotate inherently inaccurate

bugzilla-daemon at freedesktop.org bugzilla-daemon at freedesktop.org
Tue Feb 10 16:07:08 PST 2015


https://bugs.freedesktop.org/show_bug.cgi?id=89071

            Bug ID: 89071
           Summary: cairo_rotate inherently inaccurate
           Product: cairo
           Version: unspecified
          Hardware: Other
                OS: All
            Status: NEW
          Severity: normal
          Priority: medium
         Component: general
          Assignee: chris at chris-wilson.co.uk
          Reporter: terra at gnome.org
        QA Contact: cairo-bugs at cairographics.org

cairo_rotate takes its argument in radians which is one of those
things that work better on a blackboard than on a computer.

Consider the angle M_PI/2.  When this angle is rounded to its closest
"double" representative x, we have sin(x)=1 [good!] but cos(x)=6.12323e-17
[not good].

This is an API problem: the damage is already done when cairo_rotate
is entered.

Suggestions:

1. Add cairo_rotate_degrees and/or cairo_rotate_pi, the latter taking
   an angle argument that is 2 for a full rotation.

2. Make the backend api use an angle argument that is 2 for a full turn.

3. Use the IEEE 754-2008 functions sinpi and cospi in the backends
   where they currently use sin and cos.

   http://www.math.fsu.edu/~gallivan/courses/FCM1/IEEE-fpstandard-2008.pdf.gz

   The sinpi and cospi functions are fairly easy to implement.  Feel free
   to grab code from
https://git.gnome.org/browse/goffice/tree/goffice/math/go-math.c
   lines 942-1043 which also has tanpi and atan2pi.

Benefits: the matrices will actually have zeros where you would expect them.
Rotating by 90 degrees four times will actually bring you back where you
started.

-- 
You are receiving this mail because:
You are the QA Contact for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.cairographics.org/archives/cairo-bugs/attachments/20150211/0b0bcbb5/attachment.html>


More information about the cairo-bugs mailing list