feifanrensheng

atan 和 atan2 都是求反正切函数,如:有两个点 point(x1,y1), 和 point(x2,y2);

那么这两个点形成的斜率的角度计算方法分别是:

float angle = atan( (y2-y1)/(x2-x1) );

float angle = atan2( y2-y1, x2-x1 );

 

 atan 和 atan2 区别:

1:参数的填写方式不同;

2:atan2 的优点在于 如果 x2-x1等于0 依然可以计算,但是atan函数就会导致程序出错;

 

结论: atan 和 atan2函数,建议用 atan2函数;

参考:https://blog.csdn.net/chinabinlang/article/details/6802686

分类:

技术点:

相关文章:

  • 2022-12-23
  • 2022-01-31
  • 2022-02-23
  • 2021-09-07
  • 2022-01-18
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2021-07-13
  • 2021-09-01
  • 2022-12-23
  • 2021-12-10
  • 2022-12-23
相关资源
相似解决方案