[cairo] Shouldn't Cairo use/offer degrees rather than radians?

David Kastrup dak at gnu.org
Fri Jun 30 05:02:36 UTC 2017


Lawrence D'Oliveiro <ldo at geek-central.gen.nz> writes:

> On Thu, 29 Jun 2017 08:08:04 +0200, David Kastrup wrote:
>
>> Lawrence D'Oliveiro <ldo at geek-central.gen.nz> writes:
>> 
>>> You realize that, by introducing this distortion, you are reducing
>>> the accuracy of the computation?  
>> 
>> It replaces a sin(x)/cos(x) pair by a sin(x)/sin(pi/2-x) pair.  The
>> largest cumulative effect is at pi/4.
>
> So you introduce a kink at π/4. How is this any better, again?

There is no kink.  None at all.  The handover between different
functions happens at sin(pi/2) where there is a large stretch of 1.0.
At pi/4, there is no discontinuity but the sin/cos pair is taken as
(sin(pi/4), sin(pi/4)) instead of (sin(pi/4), cos(pi/4)).  Since pi/4
has no actual numeric representation, getting an exact angle of 45
degree in the transformation matrix may come at the cost of a larger
magnitude jitter of the determinant _iff_ you have a very, very accurate
sin/cos implementation.  Mind you: that jitter is still less than 2ulp
so you need a very good sin/cos implementation to even measure it.

Square the transform matrix for 45 degrees 20 times or so with the
degree function and the radian function and compare the results and see
which you like better.

I'll append the patch to Cairo to make it easier for you.

>>> I wonder what the term is, for deliberately producing inaccurate
>>> answers just to look good...  
>> 
>> A very well-considered tradeoff and solid engineering?
>
> “Engineering” is not the term that comes to mind. Try “marketing” or
> “management”.

Please compare the results.

> You do realize that your claim about Cairo’s “inability to reliably
> draw a half circle that seamlessly connects with another half circle
> under any rasterization” is complete nonsense, right?

Sigh.  If you cannot specify an angle for pi for which sin(angle)==0,
you will have rasterizations of half circle arcs that won't line up
perfectly because you then cannot make the half circles butt up
perfectly, and "too small to be noticeable" becomes a statistic rather
than a static feature under rasterization.

--
David Kastrup

-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0001-Implement-cairo_matrix_init_rotate_deg-and-cairo_mat.patch
Type: text/x-diff
Size: 5889 bytes
Desc: not available
URL: <https://lists.cairographics.org/archives/cairo/attachments/20170630/c4715117/attachment.patch>


More information about the cairo mailing list