#### Polar Coordinates

If you know how far something is from the center (say, the radius of your watch dial), and what angle it's at (say, the second-hand rotation value), and need to translate that into X and Y coordinates (e.g., moving a shape around as a second hand), you'll need these formulĂ¦. It's handy to define functions for them in the main watch script:

*function var_x(r, theta) return r*math.sin(math.rad(theta)) end**function var_y(r, theta) return -r*math.cos(math.rad(theta)) end*

Don't forget the math.rad part This is a common mistake, because it's easy to forget, and then you get mystifying results. The lua trigonometry functions (sin, cos, etc.) operate on radians, while WM (and most people) measures angles in degrees. The math.rad() function converts degrees to radians. If you need to convert from radians to degrees (say, after using an arctan function), multiply by 180/math.pi.