Find angles on a field

Hello,

I am trying to find the angle between a reference point and other points, with given coordinates. For example, my reference point is (2,-2) and I want to find the angle between this point and another one, for example,(10,1). Normally I would perform
double angle=atan(1-(-2)/10-2);

But this is not correct, because trig functions work only in radians. How can I find those angles?
Thanks
Unless I'm mistaken you need 3 points to have an angle.

Unless you're looking for the orientation of that line segment... in which case you can use atan2:

double angle = atan(1 + 2,10 - 2);

If you need degrees instead of radians, just convert:

 
angle = angle * 180 / pi;
Thanks,

Let me ask in another way: I have a triangle and I am able to calculate tan of an angle, by dividing opposite/adjacent sides. Im order to get this angle value , I need to calculate the arc tan of the value I got before. This will not work in c++, since I need the tan in radians before. My mission here is to find the angle of a right triangle, given only its length sides.

Thanks
ok, i got it. The angles I got are ok, I jst get them in rad, which is ok, because I just need to compare them
Topic archived. No new replies allowed.