Jump to content
  • Advertisement
Sign in to follow this  
Endemoniada

Angle to 2D Vector ?

This topic is 5080 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
Advertisement
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
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!