Sorry my math is very weak so it's difficult to research, this seems like it would be an obvious question that gets asked often.
I'm a budding software developer trying to write a watch face. The face is $240 \times 240$, for our purposes just consider $X(-120,+120)$ and $Y(-120,+120)$, easy enough to convert after.
Trying to derive $(X,Y)$ coordinates to draw hands based on hour/minute. Doing this case by case is easy enough. $\text{Minute} \times 6 = \theta$. This $\theta$ gets applied to $\sin / \cos$ depending on it's value.
The problem is writing it in a single function to derive. For example:
if(theta > 0 && theta <= 45) {
X = sin(theta) * 120;
Y = cos(theta) * 120;
}
else if (theta >= 45 && theta <= 90) {
X = cos(theta) * 120;
Y = sin(theta) * 120;
}
Then draw a line from [0,0] to $[X,Y]$.
Depending on the value the formula applied changes. This seems like it's surely a problem that somebody has had before. Any easy formula to account for this? Or it becomes 8 unique cases?