If I have the coordinates of two points, how would I determine what direction the second point lies in, relative to the first point? Specifically, I'm writing an application that involves basically drawing an arrow starting at a certain area on the screen, pointing in the direction of the mouse.
2026-03-28 02:10:35.1774663835
How to determine the direction of one point from another, given their coordinates?
17.5k Views Asked by Bumbble Comm https://math.techqa.club/user/bumbble-comm/detail At
1
From $(x_1, y_1)$ to $(x_2, y_2)$ the direction is $\text{atan2}(y_2 - y_1, x_2 - x_1)$
You wrote you were writing a program, so atan2 is the easiest solution, it's usually found in your languages math package. In java it's Math.atan2(y, x)