1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Apr 2007
    Rep Power

    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.

    Thanks in advance.
  2. #2
  3. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Sep 2010
    Rep Power
    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.
    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 04:50 PM.

IMN logo majestic logo threadwatch logo seochat tools logo