atan和atan2反正切计算
2024-09-29 07:53:58
typedef struct point {
double x, y;
}point;
//给定两个点
point a(x1,y1),b(x2,y2);
- 使用反三角函数atan求斜率,原型如下
float atan( float arg );
double atan( double arg );
long double atan( long double arg );
double atan( Integral arg );
double angle=atan((y2-y1)/(x2-x1));
返回值
若不出现错误,则返回 arg 在$ [- π/2 ; +π/2]$ 弧度范围中的弧(反)正切( $arctan(arg) $)。值域有限,一四象限,斜率不存在不能求。
2. 使用反三角函数atan2求斜率,原型如下
float atan2( float y, float x );
double atan2( double y, double x );
long double atan2( long double y, long double x );
Promoted atan2( Arithmetic1 y, Arithmetic2 x );
返回值
若不出现错误,则返回 y/x 在 $(-π ; +π] $弧度范围中的弧(反)正切( arctan(y/x) )。值域扩展到四个象限。
atan2(y,x)所表达的意思是坐标原点为起点,指向(y,x)的射线x轴正方向形成角的角度。在x=0的时候:
1.当y>0时,指的是绕逆时针到达射线所旋转的角的角度;
2.而当y<0时,指的是绕顺时针达到射线所旋转的角的角度。
这样就可以求两个点表示的线段(向量)和x轴正向的角度,如下
double angle=atan2((y2-y1),(x2-x1));
最新文章
- JS ECMAScript 5中的every 和 some方法进行逻辑判断
- DBUtils
- js算出生日是当年第多少天
- 【转载】Lucene.Net入门教程及示例
- JAVA中保留指定小数位方法
- rspec+rest-client测试第三方web service
- Android启停调试
- iOS:FFmpeg视频播放和直播框架
- hdu 5438 Ponds dfs
- 4.html5中超链接
- (转)log4j:WARN No appenders could be found for logger 解决方案
- MVC小系列(七)【分部视图中的POST】
- UltraEdit v17.10.0,注册机,注册码
- Android 中 GridView 常用属性合集
- Springboot 项目启动后执行某些自定义代码
- loadrunner&#160;脚本优化-参数化之场景中的参数化取值
- java 数组转字符串 字符串转数组
- var/let/const区别何在??(转载)
- ios 清除缓存文件
- 一个复杂Json的解析
热门文章
- Python pip windows安装
- git的commit规范及强制校验
- canvas的getImageData和putImageDataAPI
- MFCdll的两种调用方法
- 菜鸟学习Spring——SpringMVC注解版解析不同格式的JSON串
- mac 上配置 maven
- (四)svn 服务器端的使用之创建工程目录
- 成功解决:FutureWarning: Conversion of the second argument of issubdtype from `float` to `np.floating` is
- EM自动任务导致数据库缓慢
- Ajax 重构的步骤