Welcome, Guest. Please login or register.

Login with username, password and session length

 
Advanced search

1411283 Posts in 69325 Topics- by 58380 Members - Latest Member: bob1029

March 29, 2024, 02:22:38 AM

Need hosting? Check out Digital Ocean
(more details in this thread)
TIGSource ForumsDeveloperTechnical (Moderator: ThemsAllTook)Very basic radians and vector stuff
Pages: [1]
Print
Author Topic: Very basic radians and vector stuff  (Read 816 times)
Ankmannen
Level 1
*



View Profile WWW
« on: December 15, 2014, 02:52:27 AM »

Hi!

I'm not well versed in the way of vector math to start off Smiley

In my game I define a vector going up as {0,1} and right as {1,0}.

However, when I try to map this to rotation, With functions like the result is counter clockwise, since that's the way radians are defined.

Code:
public static float VectorToAngle(Vector2 vector)
{
    vector.Normalize();
    return (float)(Math.Atan2(vector.Y, vector.X));
}

Is this the way it is when using radians or have I missed something?

// Johan

Logged

jgrams
Level 3
***



View Profile
« Reply #1 on: December 15, 2014, 04:34:28 AM »

That's the usual direction for any unit of angular measure in mathematics: it's called a right-handed coordinate system.

But note that in computer graphics, often the display is a left-handed coordinate system, with the positive X-axis still pointing right, but the positive Y-axis pointing down, which reverses the direction of the rotation.
Logged
Ankmannen
Level 1
*



View Profile WWW
« Reply #2 on: December 15, 2014, 04:39:12 AM »

Ah alright... It also seems that Farseer Physics (which I use) defines 0 radians as up and clockwise rotation.

Thanks for your clarification!

// Johan
Logged

Pages: [1]
Print
Jump to:  

Theme orange-lt created by panic