atan2()函数以及C ++中的示例
C++atan2()函数
atan2()函数是cmath标头的库函数,用于查找y/x的反正切的主值,其中y是y坐标的比例,x是x坐标的比例,它接受两个参数(y,x),并以弧度返回y/x的反正切。
atan2()函数的语法:
atan2(y, x);
参数:y,x–是数字(y坐标和x坐标的比例),用于计算y/x的反正切的主值。
返回值:double-返回double类型的值,它是y/x的反正切的主要值。
示例
Input:
float x = -1.0;
float y = -2.5;
Function call:
atan2(y, x);
Output:
-1.9513C++代码演示atan2()函数的示例
//示例
//atan2()函数
#include <iostream>
#include <cmath>
using namespace std;
//main()部分
int main(){
float x;
float y;
x = -1.0;
y = -2.5;
cout<<"atan2("<<y<<","<<x<<"): "<<atan2(y,x)<<endl;
x = 11.0;
y = 22.5;
cout<<"atan2("<<y<<","<<x<<"): "<<atan2(y,x)<<endl;
x = -1.0;
y = 0;
cout<<"atan2("<<y<<","<<x<<"): "<<atan2(y,x)<<endl;
return 0;
}输出结果
atan2(-2.5,-1): -1.9513 atan2(22.5,11): 1.11608 atan2(0,-1): 3.14159
参考:C++atan2()函数
热门推荐
1 带狗狗训练
4 听力训练狗狗
6 怎训练狗狗
7 腹肌训练狗狗
8 网球训练狗狗
9 记叙文训练狗狗
10 狗狗太凶怎么训练
11 核心力量训练狗狗
12 狗狗乱叫怎么训练
13 发音训练狗狗
14 怎么训练狗狗叼东西给主人
15 荆州训练狗狗
16 篮球训练狗狗
17 做训练狗狗
18 训练狗狗坐姿