如何根据三角函数获得角度C++
How to get angle based on trigonometric function in C++
我知道我可以通过math.h得到给定的角度三角函数。我想知道,是否可以反向完成。
假设有一个具有两个坐标的向量。我有它的 x 和 y 值,所以切线可以很容易地计算出来
float tg;
if(x != 0)
{
tg = y/x
}
else
{
//vector is vertical and it doesn't have a tangent
//handle this somehow
}
但是,我认为没有办法反向执行此操作。我需要一种方法来根据它的切线获得 0 到 2pi 之间的角度。
使用函数angle = atan2(y, x)
以下是指向更多信息的链接:http://www.cplusplus.com/reference/cmath/atan2/
或
http://en.cppreference.com/w/cpp/numeric/math/atan2
相关文章:
- 有根的二进制搜索树.保留与其父级的链接
- 函数何时会在c++中包含stack_Unwind_Resume调用
- Python中的for循环与C++有何不同
- 根中的组合
- 套接字连接"Operation not permitted"错误,甚至使用升压/平发器根.cpp
- 在C++中释放内存期间,迭代器与指针有何不同
- 比根<操作员
- 使用根/C++时出错:没有匹配的构造函数来初始化'TTree'
- 标准对此指向成员函数类型模板参数有何说明?是我的代码有误,还是 MSVS 16.6 有问题?
- 在字符数组 (C++/根) 中查找双精度值
- 如何从命令行使用 cmake 为有根的安卓设备制作可执行文件?
- 从网站复制证书,并使用脚本将其添加到受信任的根证书颁发机构
- 从根权限进程创建可访问的文件
- 类中的 C++ int 被设置为值,似乎不知从何而来
- 提升图库示例 凯文培根的六度:示例中的 Vertex() 是什么
- -fvisibility-inline-hidden 与 gcc 中的 -fvisibility=hidden 有何不同
- 当包含头文件的文件不在根项目文件夹中时,如何包含它
- 如何遍历几个每小时一次的根(.root)文件,并将它们组合成更大的每日数据.root文件?
- 为什么我的二叉树会覆盖其根的叶子?
- C++没有标准功能的立方体根查找器