Forums: » Register « |  Free Tools |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support |

New Free Tools on Dev Shed!

#1
July 29th, 2011, 03:29 AM
Registered User

Join Date: Apr 2007
Posts: 2
Time spent in forums: 43 m 26 sec
Reputation Power: 0
Need help with game math (Angle/Points)

Hi guys,

How do I translate an angle to a direction in coordinates.
For example: 135 deg tranhslates to (1, 1)
Will move it bottom right.

#2
July 29th, 2011, 05:39 PM
 JonthnC
Contributing User

Join Date: Sep 2010
Posts: 68
Time spent in forums: 2 Days 2 h 35 m
Reputation Power: 4
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.
Code:
int degrees = 135;

float x = -sin(degrees);
float y = cos(degrees);

The above example uses a simplified version of the two dimensional rotation formula since x is known to be zero.

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.

 Viewing: Dev Shed Forums > Programming Languages > Game Development > Need help with game math (Angle/Points)