当前位置: 首页 > 文档资料 > Arduino 中文教程 >

Arduino - 三角函数( Trigonometric Functions)

优质
小牛编辑
117浏览
2023-12-01

您需要使用三角函数,就像计算移动物体的距离或角速度一样。 Arduino提供传统的三角函数(sin,cos,tan,asin,acos,atan),可以通过编写原型进行总结。 Math.h包含三角函数的原型。

三角精确语法

double sin(double x); //returns sine of x radians
double cos(double y); //returns cosine of y radians
double tan(double x); //returns the tangent of x radians
double acos(double x); //returns A, the angle corresponding to cos (A) = x
double asin(double x); //returns A, the angle corresponding to sin (A) = x
double atan(double x); //returns A, the angle corresponding to tan (A) = x

例子 (Example)

double sine = sin(2); // approximately 0.90929737091
double cosine = cos(2); // approximately -0.41614685058
double tangent = tan(2); // approximately -2.18503975868