Skip to main content
gamedev.net
🔒 Locked

Vector angles

Started by Fooberman 1 reply 550+ views
Original Post
Fooberman
Fooberman
So i have a vector V, and i have an angle ALPHA.. What i want is to find a random vector that is within ALPHA degrees of V. What I think I need to do, is randomly generate two angles that are between zero and ALPHA, and then use those to find my random vector, but i''m not sure how to generate that vector. the norms don''t matter, the direction is all i''m interested in here. Anybody know how to do this? Chris~
xyzzy00
xyzzy00
Add to V a vector P, which is perpendicular to V, and has a length less than or equal to |V|cos(ALPHA).

xyzzy
mnansgar
mnansgar
Well, assuming that you have the vector V's magnitude and direction stored, all you have to do is find a random angle V (angle) - ALPHA < angle < V (angle) + ALPHA then copy the first vector's magnitude to the new one's.

If the vector is stored in rectangular coordinates, translate it to the origin, find its direction and magnitude, do the above, convert it to rectangular coordinates, then translate it back.

Danny

Edited by - mnansgar on December 22, 2001 9:48:03 PM
h20, member of WFG 0 A.D.

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.