The diagram above shows the ray passing through the point (-4,3). The angle we want to find is labeled A. Note that,

and that -B is the angle between the positive x-axis, and
the ray through (4,-3). The same reasoning will work for any
point like (-4,3). Thus, since -B = arctan(-3/4), we
discover that for any point lying in the second quadrant, the angle we
seek is given by arctan(y/x) +
.
Doing the same analysis for a point in the third quadrant shows that
in this case the angle is also given by
arctan(y/x) +
.
If the x
coordinate of a point is negative, it must lie in either the second or
third quadrant. Hence, for a point (x,y) with x
negative, the angle is given by
arctan(y/x) +
. Otherwise, if
x is positive, the point lies in quadrant one or four, and thus
the angle already lies in the range
.
Hence in this case, arctan(y/x) is already the angle we want.
Of course, if the point lies on the y-axis, i.e. if it is of
the form (0,y), then the expression arctan(y/x) is
undefined. However, in this special case, it is clear the angle is
, where the sign depends on the sign of
y.