A degree (°) measures rotation: one full circle is 360°. Angles describe how far one line, direction, or element turns from another. In interface work, degrees make rotations readable: `rotate(45deg)` turns an element 45 degrees clockwise, while a negative value turns it counterclockwise. section 1.4.7
CSS accepts several angle units. `deg` divides a circle into 360 parts; `rad` uses radians; `grad` divides a circle into 400 parts; and `turn` treats a full circle as `1turn`. Degree values wrap around a circle, so `360deg` equals `0deg`, `450deg` equals `90deg`, and `-90deg` equals `270deg`. section 9.1.2
Use degrees directly for visual rotation, but convert them when JavaScript trigonometry needs radians:
- Convert degrees to radians with `radians = degrees * (Math.PI / 180)`. For example, 45° is `Math.PI / 4`. section 9.1.3
- Convert radians to degrees with `degrees = radians * (180 / Math.PI)`. This is useful after `Math.atan2()` calculates a pointer direction. section 9.1.3
- Use CSS degrees where the browser expects an angle, such as `element.style.transform = `rotate(${angle}deg)`;`. section 13.2.2
radians = degrees * (Math.PI / 180)
degrees = radians * (180 / Math.PI)
These paired formulas bridge CSS-friendly degree values and the radians required by JavaScript’s `Math.sin()`, `Math.cos()`, and `Math.atan2()`. section 9.1.3
Point a rotary control toward the cursor
A dial starts with mouse coordinates, finds the vector from its center to the pointer, and passes its vertical and horizontal distances to `Math.atan2()`. That result is radians, so convert it to degrees before using `rotate(...deg)`. A 90-degree adjustment can shift the reference from rightward—the usual zero-angle direction—to the top of a knob. section 13.2.2 section 13.4
Browser coordinates affect how degrees look on screen: x increases rightward and y increases downward. Thus 0° points right, 90° points down, and 45° points down and right. With a length and angle, cosine and sine turn that direction into x and y movement components. section 10.1
