We are usually in the mathematical calculation is, often use trigonometric and inverse trigonometric functions, the most commonly used inverse trigonometric functions is probably atan, because this is equivalent to a given two points between the line angle.
1, tangent function image
At this point tangent function image, high school we should know, the tangent function is a periodic function, that is, the same value, there are many angle values corresponding, then we use the MATH.H Math library function atan2 (y,x), the return of what exactly is it.
2, Radian system and angle conversion
Inverse Trigonometric Functions return value is Radian system, to change angle system, need *180/π. Pi is 3.1415926.
3, the return value of the inverse tangent function atan2
The best way to solve doubt is to practice. Because the work to calculate the two points of the angle, for (y,x) (+,+), (+,-), (-,+), (-,-), the return angle in the end is not quite sure, so use the following program to verify.
#include "stdafx.h"
#include <iostream>
using namespace std;
#define F_path "D:\\project\\testtest\\test_tan\\test_tan\\1.txt"
#define PI 3.1415926
int _tmain ( int argc, _tchar* argv[])
{
double ang = 0.0;
Double angle = 0.0;
Angle = atan2 (2.0,1.0); The
angle*180/pi ang = the;
cout << ang <<endl;
Angle = atan2 ( -2.0,1.0); -63, 4 quadrant
ang = angle*180/pi;
cout << ang <<endl;
Angle = atan2 (2.0,-1.0); 116 , 2 quadrant
ang = angle*180/pi;
cout << ang <<endl;
Angle = atan2 ( -2.0,-1.0); -116 3 quadrant
ang = angle*180/pi;
cout << ang <<endl;
Cin.get ();
return 0;
}
The result of the program running is:
In fact, the results are also very well understood, the program according to (X,y) positive and negative to determine the quadrant, the one or two quadrant is positive, three or four quadrant is negative. The return angle range is (-180,180).