python - 正切方程提供错误的输出
问题描述
我似乎无法在 Python 中找到我的数学问题的解决方案,没有文章适合这个问题。确实相信它可能存在于结构设置中,但坦率地说,根据我的知识,我没有选择。已尝试阅读该库,但它也没有提供解决方案。
简单来说就是这样:
代码运行良好,除了输出错误。
import math
descent_speed = float(150 * (1/60) * 6080 * (math.tan(3.0)))
print(descent_speed)
结果:-2166.7074547290226
现在计算的正确答案
150 = 以节为单位的地面速度 3.0 = 以度为单位的下降路径角度
150 * 1/60 * 6080 * 棕褐色(3.0) = 796.5982451
这是根据计算器计算的,等于每分钟 797 英尺。
现在我确实尝试使用 math.degrees 将 3.0 添加为学位,但这不起作用。
import math
GS = 150
slope = math.degrees(3.0)
descent_speed = float((GS) * (1/60) * 6080 * (math.tan(slope))) #code to calculate descent speed based on descent angle
print(descent_speed)
结果:-19164.534008140585
所以请帮忙,我没有想法?
解决方案
三角函数以弧度为单位进行输入。更改math.degrees
为math.radians
:
>>> help(math.tan)
Help on built-in function tan in module math:
tan(x, /)
Return the tangent of x (measured in radians).
>>> angle_in_degrees = 3.0
>>> 150 * (1/60) * 6080 * math.tan(math.radians(angle_in_degrees))
796.5982451022264
推荐阅读
- firebase - 向 Firebase 规则添加管理员权限
- ios - CoreStore 在上下文中创建对象而不保存到数据库
- spring-boot - 如何将异步数据写入远程端点而不会出现“未找到合适的写入器异常”?
- hibernate - 由于意外的 AST 节点,使用 JPA TREAT 的命名查询无法正常工作
- reactjs - 如何在复杂对象中设置 setState
- c - 有什么办法可以设置默认参数?xc8
- excel - Excel 查找/搜索和匹配
- java - 使用 java ProcessBuilder 从批处理文件运行 python 脚本不起作用
- c# - Azure webjobs JobHostConfiguration 缺失,现在无法进行设置
- r - 当组内变异显着不同时,如何解释阿多尼斯中的显着结果