atan和atan2反正切计算
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));
atan和atan2反正切计算的更多相关文章
- 反正切函数atan与atan2的区别
atan 和 atan2 都是求反正切函数,如:有两个点 point(x1,y1), 和 point(x2,y2); 那么这两个点形成的斜率的角度计算方法分别是: float angle = atan ...
- atan与atan2的区别
相比较ATan,ATan2究竟有什么不同?本篇介绍一下ATan2的用法及使用条件. 对于tan(θ) = y / x: θ = ATan(y / x)求出的θ取值范围是[-PI/2, PI/2]. θ ...
- atan 和 atan2
转自http://blog.csdn.net/chinabinlang/article/details/6802686 atan函数与atan2函数的一点区别 . atan 和 atan2 都是求反 ...
- C语言math.h库函数中atan与atan2的区别
源: C语言math.h库函数中atan与atan2的区别 C语言中的atan和atan2
- atan()与atan2()
Atan2 函数介绍 atan2原型:extern float atan2(float y, float x);用法:#include <math.h>功能:求y/x(弧度表示)的反正切值 ...
- C语言中的atan和atan2(转)
在C语言的math.h或C++中的cmath中有两个求反正切的函数atan(double x)与atan2(double y,double x) 他们返回的值是弧度 要转化为角度再自己处理下. 前者 ...
- C语言中的atan和atan2
本文内容为转载,是在阅读 RTKLIB源码时意识到的这个问题,原文地址为:https://www.cnblogs.com/dutlei/archive/2013/01/14/2860332.html ...
- TensorFlow API 汉化
TensorFlow API 汉化 模块:tf 定义于tensorflow/__init__.py. 将所有公共TensorFlow接口引入此模块. 模块 app module:通用入口点脚本. ...
- atan、atanf、atanl、atan2、atan2f、atan2l
很久不发博客了,今天在园中计算各种角,于是复习下fan正切函数 计算x的反正切值 (atan.atanf和 atanl) 或y/x 的反正切值 (atan2.atan2f和 atan2l). ...
随机推荐
- Required Integer parameter 'XXX' is not present
1.异常提示: DEBUG o.s.w.s.m.m.a.ServletInvocableHandlerMethod - Error resolving argument [2] [type=java. ...
- 前端如何使用proxyTable和nginx解决跨域问题
最近经常遇到跨域的问题,有时候问题虽然解决了,但是还是会有些模棱两可概念不清,于是在网上看了一些教程结合实际使用,做个笔记. 1.跨域原因 浏览器的限制 跨域(协议/域名/端口的不同) XMLHttp ...
- java面试题之----super和this
super和this的异同: super(参数):调用基类中的某一个构造函数(应该为构造函数中的第一条语句) this(参数):调用本类中另一种形成的构造函数(应该为构造函数中的第一条语句) supe ...
- Hadoop fs命令(转)
最近使用hive做一些etl工作,除了日常sql的编写,了解hadoop及hive的一些底层原理性质的东西包括调优非常有必要,一次hive调优就把原来的零散文件做了合并.首先记下hadoop常用的命令 ...
- Zabbix监控 windows agent安装配置
下载Windows的zabbix客户端 载地址:http://www.zabbix.com/download.php 选择windows版本的agent下载 从官方下载Zabbix Agent后,压缩 ...
- 技术blog
看到好多人都写技术blog,发现自己工作了快两年居然都没有写过blog,很是惭愧,遂从今天开始不定期更新技术体验,主要是为了记下自己学习摸索技术过程中的经验以及问题解决方案.
- LeetCodeOJ刷题之12【Integer to Roman】
Integer to Roman Given an integer, convert it to a roman numeral. Input is guaranteed to be within t ...
- IOS 多媒体 使用总结
一.音频播放 1.音效播放(短时间的音频文件)1> AudioServicesCreateSystemSoundID2> AudioServicesPlaySystemSound 2.音乐 ...
- IOS Core Motion、UIAccelerometer(加速计使用)
加速计 ● 加速计的作用 ● 用于检测设备的运动(比如摇晃) ● 加速计的经典应用场景 ● 摇一摇 ● 计步器 ● 加速计程序的开发 ● 在iOS4以前:使用UIAccelerometer,用法非常简 ...
- 关于message pack as3 版本的一些修改。
玩个人项目的时候,根据前辈的推荐开始用messagepack,分别是py版和as3版: 然后在github上找到了demonsters的as3模块,于是颠屁颠屁地拿来用了,用的时候发现了一些小地方过不 ...