Reputation: 317
I know I should know this, but I just can't figure it out/find the solution. I can do it by hand, but I can't put it in an algorithm... (working in c++, but pseudocode should be fine).
I have a vector, and I want to find another vector based on the angle with it.
v is known, angle alpha is known and the magnitude of w is known. How can I find w?
Thanks!
Upvotes: 12
Views: 17972
Reputation: 43159
To rotate a vector v = (x, y)
by an angle alpha
clockwise about the origin, you can multiply by the matrix:
[ cos alpha sin alpha ]
[ -sin alpha cos alpha ]
Thus the rotated vector with the same magnitude will be
(x cos alpha + y sin alpha, -x sin alpha + y cos alpha).
To change the magnitude from |v| to |w|, multiply both co-ordinates by |w|/|v|.
Upvotes: 20
Reputation: 173
vector(w) = vector(v) / cos (alpha) to find the direction of w. You must multiply by magnitude(w)/magnitude(v) to set the magnitude
Upvotes: -2