简介
在C/C++ sin 的参数与我们平常数学三角函数理解的不一样.
在C/C++语言中sin、cos、tan、asin、acos、atan 的参数是 弧度,而不是角度
. 所有我们计算一个角度的sin、cos、tan、asin、acos、atan 值时,应先转成弧度值.
公式如下:
弧度 = 角度 * 3.1415926 / 180.0
#include <cmath>
//sin
int angle1 = 30; // 角度
sin(angle1 * 3.1415926 / 180.0); // 获得 30度对应的 sin 值 0.5
//cos
int angle2 = 120; // 角度值
cos(angle2 * 3.1415926 / 180.0) // 120 度的 cos 值 -0.5
//tan
std:cout << tan(angle2 /180*3.1415926) << std::endl;
//asin
asin (angle2 * 3.1415926 / 180.0);
//acos
int angle3 = 120; // 角度
float cosr = cos(angle3 * 3.1415926 / 180.0) // 120 度的 cos 值-0.5
acos(cosr) * 180 / 3.1415926; // 计算返回 角度值 应是120
//atan
//atan函数输出的是弧度! 如果想进行atan运算得到角度,需要乘以(180/PI)把弧度转为角度
float atanValue1 = atan(1.0f);
float atanValue2 = atan(1.0f)*180.0f/PI;
cout<<"atan(1) = "<<atanValue1<<endl; //输出弧度
cout<<"(atan(1.0))*180/PI = "<<atanValue2<<endl; //输出角度
下面是摘自网络搜集的资料,很容易快速的理解与案例和公式:
扩展资料:
一、常用的诱导公式
任意角α与 -α的三角函数值之间的关系:
sin(-α)=-sinα.
cos(-α)=cosα.
tan(-α)=-tanα.
cot(-α)=-cotα.
sec(-α)=secα.
csc (-α)=-cscα.
二、角度制下的角的表示:
sin(180°-α)=sinα.
cos(180°-α)=-cosα.
tan(180°-α)=-tanα.
cot(180°-α)=-cotα.
sec(180°-α)=-secα.
csc(180°-α)=cscα.