Python atan2() 函数

栏目: 编程语言 · Python · 编程教程 · python 教程 · 发布时间: 8年前

内容简介:atan2() 返回给定的 X 及 Y 坐标值的反正切值。

描述

atan2() 返回给定的 X 及 Y 坐标值的反正切值。

语法

以下是 atan2() 方法的语法:

import math

math.atan2(y, x)

注意:atan2()是不能直接访问的,需要导入 math 模块,然后通过 math 静态对象调用该方法。

参数

  • x -- 一个数值。
  • y -- 一个数值。

返回值

返回给定的 X 及 Y 坐标值的反正切值。

实例

以下展示了使用 atan2() 方法的实例:

#!/usr/bin/python
import math

print "atan2(-0.50,-0.50) : ",  math.atan2(-0.50,-0.50)
print "atan2(0.50,0.50) : ",  math.atan2(0.50,0.50)
print "atan2(5,5) : ",  math.atan2(5,5)
print "atan2(-10,10) : ",  math.atan2(-10,10)
print "atan2(10,20) : ",  math.atan2(10,20)

以上实例运行后输出结果为:

atan2(-0.50,-0.50) :  -2.35619449019
atan2(0.50,0.50) :  0.785398163397
atan2(5,5) :  0.785398163397
atan2(-10,10) :  -0.785398163397
atan2(10,20) :  0.463647609001

以上所述就是小编给大家介绍的《Python atan2() 函数》,希望对大家有所帮助,如果大家有任何疑问请给我留言,小编会及时回复大家的。在此也非常感谢大家对 码农网 的支持!

查看所有标签

猜你喜欢:

本站部分资源来源于网络,本站转载出于传递更多信息之目的,版权归原作者或者来源机构所有,如转载稿涉及版权问题,请联系我们

Linked

Linked

Albert-Laszlo Barabasi / Plume / 2003-4-29 / GBP 11.24

A cocktail party. A terrorist cell. Ancient bacteria. An international conglomerate. All are networks, and all are a part of a surprising scientific revolution. Albert-L&aacuteszló Barab&a......一起来看看 《Linked》 这本书的介绍吧!

HTML 压缩/解压工具
HTML 压缩/解压工具

在线压缩/解压 HTML 代码

SHA 加密
SHA 加密

SHA 加密工具