Vector angles

Started by
1 comment, last by Fooberman 22 years, 3 months ago
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~
Advertisement
Add to V a vector P, which is perpendicular to V, and has a length less than or equal to |V|cos(ALPHA).

xyzzy
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.

This topic is closed to new replies.

Advertisement