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

David Kastrup dak at gnu.org
Tue Jun 27 06:03:36 UTC 2017

PostScript uses degrees.  PDF uses degrees.  Either have a numerically
stable presentation of right angles, the most important angles a
rectilinear coordinate system can work with.

In contrast, Cairo uses radians.  For every floating point format, PI/4
has different multiples, as opposed to 45.  You don't get guarantees
like

(1.5*M_PI/2 - M_PI) == 0.5 * M_PI

which means that detecting almost any kind of right angle reliably is a
gamble.

sin(0) = 0 in either radians or degrees, and sin(x) approximately equal
to x for small x is what makes radians popular mathematically.  But
"approximately equal" is fine to suffer from numeric aberrations, in
contrast to the relations that radians are not able to reliably provide
in standard floating point.

Representing angles as turns (with 1.0 representing an angle of 2\pi)
would also be numerically stable for important angles (though not for
the less important 30 or 60 degrees) but it hasn't caught on anywhere.

So why not provide degrees (and use them internally) for Cairo?

--
David Kastrup