# Angle between 2 points

Given the following image:

$\hskip{1.5 in}$

Supposing $A(100, 300)$ and $B(300, 100)$, how can I find the angle $\alpha$ between A and B?

On a side note, what's the main difference between a point and a vector? translating a point to a vector is as simple as Point = Vector? Sometimes I find articles where the terms are interchangable

-
Your image shows that you are asking for the angle at the origin –  Henry Apr 3 '12 at 20:49
ok, how should I edit my main question in order to describe that I want to know angle alpha? Thank you :) –  aljndrrr Apr 3 '12 at 20:52

## 3 Answers

Hint: You may have been taught about the dot product, perhaps something like $$\mathbf{a} \cdot \mathbf{b}=\left\|\mathbf{a}\right\| \, \left\|\mathbf{b}\right\| \cos \theta$$ so how might you apply that here?

-
so it's $\theta = \arccos((\mathbf{a} \cdot \mathbf{b})/(\left\|\mathbf{a}\right\| \, \left\|\mathbf{b}\right\|))$ ? –  aljndrrr Apr 3 '12 at 22:09
Yes (though you might want to take care about the sign) –  Henry Apr 3 '12 at 22:18

The Atan2 function in most computer languages will take the coordinates of a point and give the angle from the origin to that point. If you take Atan2$(B_x,B_y)-$Atan2$(A_x,A_y)$ you will have it, to within multiples of $2\pi$. If you use the usual arctangent you need to worry about which quadrant you are in.

Points are exactly that, locations in the plane (in 2D). Vectors are things with a length and a direction. You can make a correspondence between a point and the vector from the origin to that point, which seems to be what you are doing. But a vector can also be from (1,2) to (4,8), for example. This vector has coordinates (3,7).

-

Let $A={A_x \choose A_y}$. Then you subtract the angle $\angle A$ (between $A$ and the $x$-axis) from $\angle B$ (the angle between $B$ and the $x$-axis).

Use the inverse of $\tan(\angle A)=\frac{A_y}{A_x}$ to get $\alpha= \tan^{-1}(\frac{A_y}{A_x})-\tan^{-1}(\frac{B_y}{B_x})$.

-