10

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.

Angle with two vectors

v is known, angle alpha is known and the magnitude of w is known. How can I find w?

Thanks!

Tessa
  • 297
  • 1
  • 3
  • 10

2 Answers2

19

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

Simon Nickerson
  • 42,159
  • 20
  • 102
  • 127
  • 1
    Thanks! This shows exactly the expected behavior :) (Now that I see this, I even remember the slide that taught me this 6 years ago >.<). – Tessa Aug 02 '12 at 09:41
  • 1
    This solution only applies if rotation is about the origin. Nowhere in the question does it state that the vectors are about the origin. – dr_rk May 19 '15 at 13:02
  • I think it should be: (x cos alpha - y sin alpha, x sin alpha + y cos alpha) – Tony Dec 19 '17 at 04:11
-2

vector(w) = vector(v) / cos (alpha) to find the direction of w. You must multiply by magnitude(w)/magnitude(v) to set the magnitude

Phebus40
  • 173
  • 13
  • Hmm, this didn't seem to work for me. Could be that I'm doing something wrong though... – Tessa Aug 02 '12 at 09:41