To rotate a page element by one eighth of a circle, write `transform: rotate(45deg)`. A degree measures rotation: a full circle is 360 degrees, so one eighth is 45 degrees. In CSS rotation, positive angles turn clockwise and negative angles turn counterclockwise. section 1.4.7
CSS writes degrees with the `deg` unit. Angles wrap after a full turn: `360deg` has the same direction as `0deg`, `450deg` as `90deg`, and `-90deg` as `270deg`. CSS can also express angles in radians (`rad`), gradians (`grad`), or turns (`turn`). section 9.1.2
Convert an angle for JavaScript
CSS commonly uses `deg`, but JavaScript’s `Math` trigonometric functions take unitless radians. Convert before calling one: `const radians = degrees * (Math.PI / 180); const x = Math.cos(radians);`. For the reverse conversion, use `const degrees = radians * (180 / Math.PI);`. Thus 135 degrees is `3π/4` radians, or approximately 2.356. section 9.1.3 section 9.5
Turn a pointer position into a dial angle
A rotary control starts with the pointer’s position relative to the dial center: `deltaX = e.clientX - centerX` and `deltaY = e.clientY - centerY`. Get its direction with `Math.atan2(deltaY, deltaX)`, convert the returned radians using `* (180 / Math.PI)`, then apply the resulting angle with `rotate(${angle}deg)`. If the indicator’s zero position is at the top rather than the right, adjust the angle by 90 degrees. section 13.2.2 section 13.4
Keep the coordinate system in mind when checking a result. Browser coordinates increase to the right and downward, so a rightward direction is 0 degrees and a downward direction is 90 degrees. Degrees make a visual rotation easy to specify; converting units and choosing the right zero direction make calculated rotations behave as intended. section 10.1 section 9.1.3

