I have two points, one is always at the origin (0,0), and the other can be anywhere else in the world. I\'d like to find the angle between them, respective to the horizontal axi
Most programming languages/APIs provide a function, atan2(), which finds the angle and takes the quadrant into consideration. Just use that.
First we would like to find the equation of the straight line that connects the two points:
Let p = (x0,y0) be the second point. if x=0 than the answer is 90 deg. otherwise let m be y0/x0.
y = m(x-x0) +y0
tg^-1 (that is arctg) of m is the angle.
also note that if (x0,y0) == (0,0) than the angle is undefined