查看“︁Atan2”︁的源代码
←
Atan2
跳转到导航
跳转到搜索
因为以下原因,您没有权限编辑该页面:
您请求的操作仅限属于该用户组的用户执行:
用户
您可以查看和复制此页面的源代码。
{{article issues| {{expand|time=2011-04-10T05:23:28+00:00}} {{refimprove|time=2019-08-16T19:39:48+00:00}} {{expand language|1=en|page=atan2|time=2019-08-16T19:39:48+00:00}} }} 在[[三角函数]]中,两个参数的[[函数]]<math>\operatorname{atan2}</math>是[[正切函数]]<math>\tan</math>的一个变种。对于任意不同时等于0的实参数<math>x</math>和<math>y</math>,<math>\operatorname{atan2}(y,x)</math>所表达的意思是坐标原点为起点,指向<math>(x,y)</math>的射线在坐标平面上与x轴正方向之间的角的角度。当<math>y>0</math>时,射线与x轴正方向的所得的角的角度指的是x轴正方向绕逆时针方向到达射线旋转的角的角度;而当<math>y<0</math>时,射线与x轴正方向所得的角的角度指的是x轴正方向绕顺时针方向达到射线旋转的角的角度。 在几何意义上,<math>\operatorname{atan2}(y,x)</math>等价于<math>\operatorname{atan}(\frac{y}{x})</math>,但<math>\operatorname{atan2}</math>的最大优势是可以正确处理<math>x=0</math>而<math>y\neq 0</math>的情况,而不必进行会引发[[除以零|除零异常]]的<math>\frac{y}{x}</math>操作。 <math>\operatorname{atan2}</math>函数最初在计算机编程语言中被引入,但是现在它的应用在科学和工程等其他多个领域十分常见。他的出现最早可以追溯到[[FORTRAN]]语言<ref>{{Cite book | last = Organick | first = Elliott I. | authorlink = | coauthors = | year =1966 | title =A FORTRAN IV Primer | publisher = Addison-Wesley | location = | quote ="Some processors also offer the library function called ATAN2, a function of two arguments (opposite and adjacent)." | pages = 42 }}</ref>,并且可以在[[C语言]]的数学标准库的math.h文件中找到,此外在[[Java]]数学库、[[.NET]]的System.Math(可应用于[[C♯|C#]]、[[VB.NET]]等语言)、[[Python]]的数学模块以及其他地方都可以找到atan2的身影。许多脚本语言,比如[[Perl]],也包含了C语言风格的atan2函数<ref>The [[Linux API|Linux Programmer's Manual]] [http://linux.die.net/man/3/atan2] {{Wayback|url=http://linux.die.net/man/3/atan2|date=20110316203135}} says: : "The '''atan2'''() function calculates the [[arc tangent]] of the two variables '''''y''''' and '''''x'''''. It is similar to calculating the arc tangent of '''''y''''' / '''''x''''', except that the [[Positive and negative numbers|signs]] of both arguments are used to determine the [[Cartesian coordinate system|quadrant]] of the result."</ref>。 ==函数定义== 该函数基于值域为 <math>\left ( -\frac{\pi}{2}, \frac{\pi}{2} \right )</math> 的[[反正切]]函数,定义如下: :<math>\operatorname{atan2}(y, x) = \begin{cases} \arctan\left(\frac y x\right) & \qquad x > 0 \\ \arctan\left(\frac y x\right) + \pi& \qquad y \ge 0 , x < 0 \\ \arctan\left(\frac y x\right) - \pi& \qquad y < 0 , x < 0 \\ +\frac{\pi}{2} & \qquad y > 0 , x = 0 \\ -\frac{\pi}{2} & \qquad y < 0 , x = 0 \\ \text{undefined} & \qquad y = 0, x = 0 \end{cases}</math> 说明''':''' * 该函数的值域为<math>\left( -\pi,\pi\right]</math>,可以通过对负数结果加<math>2\pi</math>的方法,将函数的结果映射到<math>\left [ 0,2\pi\right )</math>范围内。 ==其他软件中的变形== 不同计算机语言中该函数的实现各有差异。 vb6: atan2(x,y)= (x<>0+y<>0)* (x<=0)*2*Atn(sgn(y)^sgn(y))/2^(x<>0)- (x<>0)*Atn(y*x^(x<>0)) adodb.connect.execute: SELECT (x<>0+y<>0)*(x<=0)*2*Atn(sgn(y)^sgn(y))/2^(x<>0)-(x<>0)*Atn(y*x^(x<>0)) AS AT_ FROM (SELECT Col1 AS x,Col2 AS y) T_ (x<>0+y<>0)可省略 ==有关图片== [[File:Atan2 60.svg|thumb|right|320px|单位圆内的atan2取值]] 旁边的图片显示内容是:在一个单位圆内<math>\operatorname{atan2}</math>函数在各点的取值。圆内标注代表各点的取值的幅度表示。 图片中,从最左端开始,角度的大小随着逆时针方向逐渐从<math>-\pi</math>增大到<math>+\pi</math>,并且角度大小在点位于最右端时,取值为0。 另外要注意的是,函数<math>\operatorname{atan2}(y,x)</math>中参数的顺序是倒置的,<math>\operatorname{atan2}(y,x)</math>计算的值相当于点<math>(x,y)</math>的角度值。 下方的图片显示的是单位圆上各点在atan2函数上的值,从原点射向<math>(0,1)</math>点的射线,开始绕逆时针方向可以与x轴正方向得到对应各点的复平面的复角,其中几个特殊点取值: *<math>(0,1)</math>对应的复平面夹角为<math>\frac{\pi}{2}</math>, *<math>(-1,0)</math>对应复平面的夹角为<math>\pi</math>, *<math>(0,-1)</math>对应复平面的夹角为<math>\frac{3\pi}{2}</math>, *回到<math>(1,0)</math>复平面的夹角为<math>0=(2n\pi \mod 2\pi)</math>。 这些你可以直观地从图中看出。<ref>{{Cite web |url=http://www.mndynamics.com/indexp.html |title=Computation of the external argument by Wolf Jung |accessdate=2011-04-10 |archive-date=2011-07-14 |archive-url=https://web.archive.org/web/20110714104650/http://www.mndynamics.com/indexp.html |dead-url=no }}</ref> <center> [[File:Atan2-discontinuity.svg]] </center> 下面的插图分别显示的是<math>\operatorname{atan2}(y,x)</math>和<math>\operatorname{atan}(\frac{y}{x})</math>在坐标平面的三维景象。 注意在<math>\operatorname{atan2}(y,x)</math>函数中,从原点辐射出的射线上有常数值,而在<math>\operatorname{atan}(\frac{y}{x})</math>的函数中,经过原点的直线有常数值。 <center> [[Image:Atan2Diagram.png|400px]] [[Image:AtanDiagram.png|400px]] </center> ==参考文献== {{reflist}} ==参见== *[[辐角]] *[[复数 (数学)|复数]] *[[反三角函数]]中的[[反正切]]([[正切函数]]的[[反函數]]) ==外部链接== *[http://java.sun.com/javase/6/docs/api/java/lang/Math.html#atan2%28double,%20double%29 Java 1.6 SE JavaDoc]{{Wayback|url=http://java.sun.com/javase/6/docs/api/java/lang/Math.html#atan2%28double,%20double%29 |date=20090829081338 }} *[http://www.cplusplus.com/ref/cmath/atan2.html C++ Programmer's Reference]{{Wayback|url=http://www.cplusplus.com/ref/cmath/atan2.html |date=20011005031348 }} {{三角函數}} [[Category:反三角函数]]
该页面使用的模板:
Template:Article issues
(
查看源代码
)
Template:Cite book
(
查看源代码
)
Template:Cite web
(
查看源代码
)
Template:Reflist
(
查看源代码
)
Template:Wayback
(
查看源代码
)
Template:三角函數
(
查看源代码
)
返回
Atan2
。
导航菜单
个人工具
登录
命名空间
页面
讨论
不转换
查看
阅读
查看源代码
查看历史
更多
搜索
导航
首页
最近更改
随机页面
MediaWiki帮助
特殊页面
工具
链入页面
相关更改
页面信息