TITLE: Find angle in degrees from one point to another in 2D space?
QUESTION [19 upvotes]: Given Point A and Point B in 2D space, how can I find the angle Point B is from Point A? 0° can be any direction; it doesn't matter. For example, Point A is at (0, 10) and Point B is at (10, 20). The angle is 45° in this example (assuming 0° is up).

REPLY [31 votes]: I believe that the accepted answer does not correctly solve the problem for many people visiting this question. I am doing 2D simulations and the answer above does not solve my problem. Imagine the following circle:
$\hskip1.8in$
Assume that the middle of the circle is point A. Point B is at some angle from A according to the angles of the circle (so 0°) is right.
$\hskip2in$The atan2 function is what you need!
$$ atan2(y, x) $$
$\hskip3.2in$ Where
$$ y = y_B - y_A $$
$$ x = x_B - x_A $$
Read more about it here.