# [cairo] Specifying Angles

Lawrence D'Oliveiro ldo at geek-central.gen.nz
Wed Mar 25 13:15:58 PDT 2015

```First of all, there is no question radians are the right unit to use
for angle calculations. However, they are not the most convenient unit
for users to specify and examine angles. (How much of an angle is
“1.5707963267948966”?)

Because my Cairo binding is in Python, you can use the standard Python
math.degrees and math.radians conversion functions. But I decided this
wasn’t convenient enough. So I also provide a couple of constants,
“deg” and “circle”. Multiplying a number of degrees by “deg” converts
it to radians (and dividing converts the other way), while multiplying
and dividing by “circle” similarly converts to/from units of a whole

Thus, the following angle specifications are all equivalent:

math.pi / 2
90 * deg
circle / 4

And converting an angle to degrees or circles can also be easily done:

>>> Vector(0, 1).angle()
1.5707963267948966
>>> Vector(0, 1).angle() / deg
90.0
>>> Vector(0, 1).angle() / circle
0.25
```