Bug 89071 - cairo_rotate inherently inaccurate
Summary: cairo_rotate inherently inaccurate
Status: RESOLVED MOVED
Alias: None
Product: cairo
Classification: Unclassified
Component: general (show other bugs)
Version: unspecified
Hardware: Other All
: medium normal
Assignee: Chris Wilson
QA Contact: cairo-bugs mailing list
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2015-02-11 00:07 UTC by M Welinder
Modified: 2018-08-25 13:42 UTC (History)
0 users

See Also:
i915 platform:
i915 features:


Attachments

Description M Welinder 2015-02-11 00:07:08 UTC
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.
Comment 1 GitLab Migration User 2018-08-25 13:42:11 UTC
-- GitLab Migration Automatic Message --

This bug has been migrated to freedesktop.org's GitLab instance and has been closed from further activity.

You can subscribe and participate further through the new bug through this link to our GitLab instance: https://gitlab.freedesktop.org/cairo/cairo/issues/148.


Use of freedesktop.org services, including Bugzilla, is subject to our Code of Conduct. How we collect and use information is described in our Privacy Policy.