Sign in to follow this  

Angle to 2D Vector ?

This topic is 4715 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi guys, I'm trying to build an angle table that will store normalized 2D vectors. When I do this: rad=AngleToRed(ang); // just PI/180.0 v.x=sin(rad); v.y=cos(rad); ...the zero angle faces North and subsequent angles go clockwise. Is that the way it's supposed to be ? It's confusing because when I use atan2() the zero angle is East (the positive x-axis) and they go counter-clockwise (which seems more natural ro me.) Thanks. I'm using VC++ 6 if that matters.

Share this post


Link to post
Share on other sites
You'll have to swap cos and sin, and possibly negate the y-coord to use the screen's coordinate system instead of the standard mathematical one.

Share this post


Link to post
Share on other sites
A vector of unitary lenght can be expressed by its angle a


v[a] = vector(cos(a), sin(a))

where
a is the angle you rotate (1,0) CCW to get v[a]


with this definition


v[0] = vector(cos(0),sin(0)) = vector(1,0) = x

when a increase v rotates CCW


so you need a look up table to store only cosine and sine values.

Share this post


Link to post
Share on other sites

This topic is 4715 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this