Mac*_*ban -1 c++ trigonometry angle
我知道我可以通过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
}
Run Code Online (Sandbox Code Playgroud)
但是,我认为没有办法反过来这样做.我需要一种基于它的切线来获得0到2pi之间的角度的方法.
使用此功能angle = atan2(y, x)
以下是更多信息的链接:http://www.cplusplus.com/reference/cmath/atan2/
要么
http://en.cppreference.com/w/cpp/numeric/math/atan2
| 归档时间: |
|
| 查看次数: |
854 次 |
| 最近记录: |