Angle to 2D Vector ?

Started by
1 comment, last by blizzard999 19 years, 3 months ago
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.
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.
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.

This topic is closed to new replies.

Advertisement