Finding directional angle of vector in $\mathbb{R}^2$

78 Views Asked by At

I'm not sure if this is correct or not and need someone to check.

I have a vector $\vec{v} = 4\left(\frac{-1}{2}, 1\right) - \frac{1}{2}(4, 8)$

I simplified it to $(-4, 0)$

So the directional angle should be the $\arctan(0)$, right? That's just $0$, though. Is it $180^\circ$ because of the $-4$?

1

There are 1 best solutions below

0
On

In general, the angle $0 \le \alpha \le \pi$ between two vectors $\vec{u} \ne \vec{0}$ and $\vec{v} \ne \vec{0}$ is:

$$ \alpha = \arccos\left(\frac{\vec{u}\cdot\vec{v}}{||\vec{u}||\,||\vec{v}||}\right). $$

So, the angle $-\pi < \beta \le \pi$ between $\vec{u} = (1,0)$ and $\vec{v} = (x,y) \ne (0,0)$ is:

$$ \beta = \begin{cases} - \arccos\left(\frac{x}{\sqrt{x^2+y^2}}\right) & \text{if} \; y<0 \\ + \arccos\left(\frac{x}{\sqrt{x^2+y^2}}\right) & \text{if} \; y \ge 0 \end{cases} $$

or equivalently:

$$ \beta = \text{atan2}(y,x) := \begin{cases} \arctan(y/x) & \text{if} \; x > 0 \\ \arctan(y/x) + \pi & \text{if} \; x < 0 \, \land y \ge 0 \\ \arctan(y/x) - \pi & \text{if} \; x < 0 \, \land y < 0 \\ +\pi/2 & \text{if} \; x = 0 \, \land y > 0 \\ -\pi/2 & \text{if} \; x = 0 \, \land y < 0 \\ \end{cases}\,. $$

Therefore, in your case we have $\beta = \text{atan2}(0,-4) = \pi$, as you correctly wrote.