How can I get a rotation angle from a $2d$ vector?

6.4k Views Asked by At

I have a $2d$ vector $(x,y)$.

And I'd like to obtain from it a rotation angle.

For example:

I would have $0^\circ$ degree when ($x = \text{positive}$, $y = 0$), more than $0^\circ$ degree when ($x = \text{positive}$, $y = \text{positive}$), and less than $0^\circ$ degree when ($x = \text{positive}$, $y = \text{negative}$)

I can't figure out how to do it

2

There are 2 best solutions below

0
On BEST ANSWER

From vector algebra you can recall to the formula for finding the angle between two vectors $a$ and $b$($cos\phi=\frac{a*b}{|a||b|}$). Than apply that formula for the given vector and the coordinate vector (1,0). So you'll have $cos\phi=\frac{x}{\sqrt{x^2+y^2}}$ or $\phi=arccos\frac{x}{\sqrt{x^2+y^2}}$.

0
On

Let $\overrightarrow{AB}\bigl(\begin{smallmatrix}x\\y\end{smallmatrix}\bigr)$ be that vector. the angle  is the vector rotation

enter image description here

Based on the law of sines we can say that $\frac{y}{sin(Â)}=\frac{m}{sin(Ĉ)}$.

So $Â=sin\mathrm{}^{-1}(\frac{y\;\cdot\;sin(90°)}{m})$

And we know that $sin (90°)$ is 1

So it becomes $Â=sin\mathrm{}^{-1}(\frac{y}{m})$

Now we have to compute the m (magnitude of the vector):

$m = \sqrt{x²+y²}$

Finally.

$$\boldsymbol{Â=sin\mathrm{}^{-1}(\frac{y}{\sqrt{x²+y²}})}$$