typedef struct point {
double x, y;
}point;
//给定两个点
point a(x1,y1),b(x2,y2);
  1. 使用反三角函数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反正切计算的更多相关文章

  1. 反正切函数atan与atan2的区别

    atan 和 atan2 都是求反正切函数,如:有两个点 point(x1,y1), 和 point(x2,y2); 那么这两个点形成的斜率的角度计算方法分别是: float angle = atan ...

  2. atan与atan2的区别

    相比较ATan,ATan2究竟有什么不同?本篇介绍一下ATan2的用法及使用条件. 对于tan(θ) = y / x: θ = ATan(y / x)求出的θ取值范围是[-PI/2, PI/2]. θ ...

  3. atan 和 atan2

     转自http://blog.csdn.net/chinabinlang/article/details/6802686 atan函数与atan2函数的一点区别 . atan 和 atan2 都是求反 ...

  4. C语言math.h库函数中atan与atan2的区别

    源: C语言math.h库函数中atan与atan2的区别 C语言中的atan和atan2

  5. atan()与atan2()

    Atan2 函数介绍 atan2原型:extern float atan2(float y, float x);用法:#include <math.h>功能:求y/x(弧度表示)的反正切值 ...

  6. C语言中的atan和atan2(转)

    在C语言的math.h或C++中的cmath中有两个求反正切的函数atan(double x)与atan2(double y,double x)  他们返回的值是弧度 要转化为角度再自己处理下. 前者 ...

  7. C语言中的atan和atan2

    本文内容为转载,是在阅读 RTKLIB源码时意识到的这个问题,原文地址为:https://www.cnblogs.com/dutlei/archive/2013/01/14/2860332.html ...

  8. TensorFlow API 汉化

    TensorFlow API 汉化 模块:tf   定义于tensorflow/__init__.py. 将所有公共TensorFlow接口引入此模块. 模块 app module:通用入口点脚本. ...

  9. atan、atanf、atanl、atan2、atan2f、atan2l

    很久不发博客了,今天在园中计算各种角,于是复习下fan正切函数 计算x的反正切值 (atan.atanf和 atanl) 或y/x 的反正切值 (atan2.atan2f和 atan2l).     ...

随机推荐

  1. Java 条件语句

    1.if...else 一个 if 语句包含一个布尔表达式和一条或多条语句. if(布尔表达式) { //如果布尔表达式为true将执行的语句 }else{ //如果布尔表达式为false将执行的语句 ...

  2. 将金额数字转换为大写汉字的js函数

    //将金额数字转换为大写汉字的函数 function convertCurrency(money) { //汉字的数字 var cnNums = new Array('零', '壹', '贰', '叁 ...

  3. Libxml2 学习

    Libxml2 学习 1.概要 libxml 是一个实现操作XML数据功能的开源C语言库. API参考文档  http://xmlsoft.org/html/libxml-tree.html 2.wi ...

  4. Thrift笔记(五)--Thrift server源码分析

    从(四)server代码跟进 public static void simple(MultiplicationService.Processor processor) { try { TServerT ...

  5. SharePoint 2013 - Add-ins

    1. App Web & Host Web The special website to which the app is deployed is called an App Web. The ...

  6. CSS3控制单行文本的溢出

    text-overflow用来设置是否使用一个省略标记(...)标示对象内文本的溢出.语法: 但是text-overflow只是用来说明文字溢出时用什么方式显示,要实现溢出时产生省略号的效果,还须定义 ...

  7. Matlab GUI读入图片

    % --- Executes on button press in pushbutton1. function pushbutton1_Callback(hObject, eventdata, han ...

  8. Scope_Pre_Post

    @Scope , 设置bean的生命周期,示例:   @Scope(value="prototype")//设置生存范围,一般用 singleton或prototype 14.@P ...

  9. C# winform 跨线程修改界面

    我们可以使用invoke和bengininvoke invoke同步执行一个委托 begininvoke异步执行一个委托

  10. SAP成都研究院廖婧:SAP C4C社交媒体集成概述

    曾经有朋友在知乎上向我提问,咨询在SAP成都研究院工作的体验. 当时,我的回答提到一点,SAP注重工作与生活的平衡,这也是SAP中国官网强调的一点. https://www.sap.com/china ...