Python 数学模块显示完全错误的结果?

标签 python math module trigonometry

我不知道我做错了什么。

from math import *
# triangle Law of Sines test:
a = float(3)
b = float(3)
c = 4.24264

A = float(45)
B = float(45)
C = float(90)

# it should be equal to the diameter of the triangle's 
# ...circumcircle when convert radians to degrees (2.12132) :
print a /sin(A)
print c /sin(C)

# and just test angles :
print degrees( sin( float(45) ) ) # 'SHOULD BE 2.8284'
print degrees( sin( float(90) ) ) # 'SHOULD BE 1'

...以及打印输出:

>> 3.52566408941
>> 4.74570003753
>> 48.7531807286
>> 51.2222357231

最佳答案

您应该执行以下操作:

sin(radians(90)) 

radians将给定角度从度数转换为弧度,并且由于 sin 需要 弧度,现在它应该按照您的预期打印 1。

关于Python 数学模块显示完全错误的结果?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32495683/

相关文章:

python - 无法理解 "Collective intelligence"程序中的一行

python - 在二维中扩展 numpy 数组的最简单方法是什么?

javascript - 有没有更聪明的方法来替换这个 CSS 列 JS?

在 C 中创建模块系统(动态加载)

database - Ionize CMS - 带有第二个数据库的模块

python - 使用 numba 时引发异常

python - 查找正则表达式中出现数字 (5-10) 的地方

python - Divio Cloud 本地 Docker 数据库连接

language-agnostic - round() 和 trunc() 函数有什么区别?

模块化方式的 Java Swing + MVC 模式