How to calculate a vector from an angle with another vector in 2D?

I know I need to know this, but I just can't figure it out / find a solution. I can do it manually, but I can't put it in an algorithm ... (works in C ++, but the pseudo code 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 it is known, the angle ฮฑ is known and the value of w is known. How can i find w?

Thank!

+5
source share
2 answers

To rotate the vector v = (x, y)angle alphaclockwise relative to the origin, you can multiply by the matrix:

[  cos alpha    sin alpha ]
[ -sin alpha    cos alpha ]

Thus, a rotated vector with the same magnitude will be

(x cos alpha + y sin alpha, -x sin alpha + y cos alpha).

To change a value from | v | to | w |, multiply both coordinates by | w | / | v |.

+10

vector (w) = vector (v)/cos (alpha), w. (w)/ (v),

-1

All Articles