0

I want to extract x and y based on an angle. See below.

enter image description here

So if the angle is 45 degrees, x would be 0.5 and y would be 0.5.

The only way I can think of solving this would be to separate the circle in 4 parts and use the Pythagorean theorem. This would require four separate formulas to account for each quadrant. I'm sure there is a better "one size fits all" formula?

EDIT:

Used this formula: x = cos(angle * (Math.PI / 180)); y = sin(angle * (Math.PI / 180));

2 Answers2

0

What you seem to be looking for are the formulas $x=\sin(\text{angle})$ and $y=\cos(\text{angle})$. Note that $x=y=\frac{\sqrt2}2$ when the angle is $45^\circ$, not $0.5$, as you say.

Cameron Buie
  • 102,994
0

For a more general, "one size fits all" approach, check the trigonometry functions on the unit circle.

Vedran Šego
  • 11,372