Re: Shouldn't Cairo use/offer degrees rather than radians?

Lawrence D'Oliveiro <[email protected]>
Newsgroups gmane.comp.lib.cairo
Organization Geek Central
Message-ID <[email protected]>
On Tue, 27 Jun 2017 17:46:50 +0200, David Kastrup wrote:

> It wasn't good enough for PostScript, and it wasn't good enough for
> METAFONT, and its author Donald Knuth basically _founded_ computer
> science as a discipline.

Having used graphics APIs with both radians and degrees, I end up
preferring radians as the underlying common unit. Maybe it’s because I
don’t just draw things, I also frequently need to calculate various
geometrical properties as well. Radians ends up being easier for this.

Though I accept that humans usually find angles easier to understand
when expressed in degrees, or even in fractions of a whole circle.
Thus, it is handy to be able to accept input and display output in
these units, while doing all calculations internally in radians.

By the way, languages like Python and Java commonly offer conversion
functions between radians and degrees. I find this a less-than-optimal
way of doing things, because you need two conversion functions (one in
each direction) for each unit. Better to offer a single conversion
factor: multiply by that factor to convert the unit to radians, divide
by it to convert radians to that unit. This is what I did in Qahirah: I
offer both “deg” and “circle” factors, so for example a right angle
can be expressed as any of

    math.pi / 2
    90 * qahirah.deg
    qahirah.circle / 4

and conversely it is easy to convert radians to the desired units:

    math.atan2(1, 1) / qahirah.deg # 45°
    math.atan2(1, 1) / qahirah.circle # one eighth of a circle
-- 
cairo mailing list
[email protected]
https://lists.cairographics.org/mailman/listinfo/cairo
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.