在我的数学课上,我们目前在学习基本的三角学单元,包括正弦定律/余弦定律。我偶尔会编写程序,让我输入已知值,并在我无聊时从该输入中获得答案。
但是,我正在为正弦定理边/边/角规则而苦苦挣扎。我正在使用这个问题作为测试(对质量表示歉意):
在纸上计算时,大约等于 15 度。
这是我的代码:
# SSA
x = float(input("Known Angle Degrees: "))
y = float(input("Length of Side Opposite Known: "))
z = float(input("Length of Side Opposite Unknown: "))
a = (math.sin(math.radians(x))/y)*z
b = math.asin(a)
print(str(a))
print(str(b))
这是我得到的结果:
Known Angle Degrees: 48
Length of Side Opposite Known: 63
Length of Side Opposite Unknown: 22
0.2595108914365504
0.26251570863497786
在获得 a 的反/反正弦之前,它显然一切正常。我只是不确定这里出了什么问题。当获取 b 的值时,我尝试将 A 转换为弧度和小数,而不是使用 asin(),而是使用 sin() 提高到 -1。什么都没用。
有什么想法吗?
编辑:抱歉,我没有包括我导入了 math
模块。对不起。
最佳答案
您只是缺少从弧度到度数的转换:
>>> math.degrees(math.asin(0.2595108914365504))
15.041042160670253
关于python - 计算正弦定律的问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/61845928/