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

David Kastrup dak at gnu.org
Tue Jun 27 09:37:07 UTC 2017


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

> On Tue, 27 Jun 2017 10:24:18 +0200, Guillermo Rodriguez wrote:
>
>> 2017-06-27 9:57 GMT+02:00 Lawrence D'Oliveiro:
>>
>>> On Tue, 27 Jun 2017 08:03:36 +0200, David Kastrup wrote:
>>>  
>>>> PostScript uses degrees.  PDF uses degrees.  
>>>
>>> No!  
>> 
>> Actually, yes..
>
> Trig calculations are usually easier in radians.

Nobody uses Taylor series for actual trig calculations.  The Cordic
algorithms work from full revolutions.

If I write

#include "math.h"
#include "stdio.h"

int
main ()
{
  printf ("%lg\n", cos (M_PI/2));
  return 0;
}

and run it, the output is 6.12323e-17 .  So apparently radians do not
make things easy enough for computer/user to work well in graphics
applications.

If you want to turn something by exactly 90 degrees or 180 degrees (not
exactly a rare event in graphics), you cannot do so by using a Cairo
function accepting angle arguments but have to specify the transform
matrix manually.

That is one important reason that graphics formats like SVG, PostScript
and PDF specify angles in degrees: that way right angles are actually
representable.

-- 
David Kastrup



More information about the cairo mailing list