Douglas Crockford

Blog

Books

Videos

2024 Appearances

JavaScript

Misty

JSLint

JSON

Github

Electric Communities

Mastodon/Layer8

Flickr Photo Album

ResearchGate

LinkedIn

Pronouns: pe/per

About

Cycles

Most people measure angles in degrees (0 ... 360). Most mathematicians measure angles in radians (0 ... ). But as a programmer, I think it is best to measure in cycles (0 ... 1). It is trivial to correct over-rotation (discard the integer part). It is trivial to find the quadrant (the two most significant bits). Table lookup implementations of sine are trivial as well.

All three units work, and each is easily convertible into the others.

cycle    =   radian / (2 * π)   =   degree / 360
degree   =   radian * 180 / π   =   cycle * 360
radian   =   degree * π / 180   =   cycle * 2 * π

When converting between radians and degrees, there is an implicit step where values are first converted to cycles.

Programming languages should make cycles the standard angular unit. It is the most convenient for programming. It is less baffling to normal people than radians. If you know how to give a dial a quarter turn, you understand cycles. Computers can express cycles exactly. Computers have trouble with π.

Mathematicians may still have reasons to prefer radians, but they are smart enough to know how to do the conversion if they have to.