How to calculate an angle for a vector?

170 Views Asked by At

I have a vector v and I want to know its angle from "12 o'clock" (i.e. u=(0,1) going straight up). According to the Internet, I can use the formula as follows.

p = u * v = 0*v_x + 1*v_y = v_y
m = |u| = 1
n = |v| = sqrt(v_x^2 + v_y^2)
a = acos(p / m / n)

What doesn't make sense to me is that we apparently only consider the vertical dimension of the vector. I don't get it and it feels plain wrong. I must be missing something but I can't see what. Is the formula only applicable for certain angles (like the first quadrant or such)?

2

There are 2 best solutions below

0
On BEST ANSWER

You are wrong to say that it only depends on the vertical dimension of the vector $v_y$. Note that $v_x$ is a hidden term in $n$, which you divide by to compute the angle.

Computing angles between vectors amounts to solving the formula $$v\cdot w = |v||w|\cos\theta,$$ where $\theta$ is the angle between the vectors. Again, you should read a little about dot products, since they come up all the time in geometry.

2
On

You are using the dot product. If you have two vector $u$, $v$ then the dot product is $$u \cdot v = \| u \|\| v \| \cos{\theta},$$ where $\theta$ is the angle between the vectors. The dot product is also calculated from two vectors as $u \cdot v = x_1x_2+y_1y_2$. If we assume that the twelve o' clock (unit) vector has the coordinates x = 0, y = 1 your dot product will now be $u \cdot v = 0 \cdot x + 1\cdot y$. Substitute this into the above equation and solve for $\theta$ and you will get $\theta = \arccos{\frac{0\cdot x + 1\cdot y}{\sqrt{x^2 +y^2}}}$