July 29th, 2011, 03:29 AM
Need help with game math (Angle/Points)
How do I translate an angle to a direction in coordinates.
For example: 135 deg tranhslates to (1, 1)
Will move it bottom right.
Thanks in advance.
July 29th, 2011, 05:39 PM
What your asking is relatively simple; start with a point at (0, 1) and rotate it the number of degrees that you want for the desired effect.
The above example uses a simplified version of the two dimensional rotation formula since x is known to be zero.
int degrees = 135;
float x = -sin(degrees);
float y = cos(degrees);
Also, in your above post don't you mean 135 degrees would translate to (1, -1)?
Last edited by JonthnC; July 29th, 2011 at 05:50 PM.