如何在python中编写数学公式

时间:2011-09-17 18:44:59

标签: python math

我尝试在python中编写这些公式但没有运气
enter image description here


我在代码中没有错误,但我知道计算得出的结果不正确,所以我猜我在实现公式时有些错误。


    import math
   lat = 54.5917455423
   lon = 17.2078876198

B = math.radians(lat)
L = math.radians(lon)
h = 55.889
pi = math.pi
a = 6378137
b = 6356752.3141
f = 1/298.257222101
ba = 1 - f# should be b/a = 1 - f

e = 0.006694380036
Da = 108
Df = - 4.80812 * 10 **-7
m = 0.000004848#one second in radians

dX = -23.74
dY = +123.83
dZ = +81.81
sin = math.sin
cos = math.cos
Rn = a/ math.sqrt(1-e**2 * math.sin(B)**2)
Rm = a*(1-e**2)/(1-e**2 * sin(B)**2)**(3/2)
vc = (Rm+h)*sin(m)

dB = (-dX*sin(B)*cos(L) - dY*sin(L) + dZ*cos(B) + Da*(Rn * e**2*sin(B)*cos(B)/a+Df)*(Rm*(a/b)+Rn*ba)*sin(B)*cos(B))*vc**-1
dL = (-dX * sin(L) + dY * cos(L) ) * ((Rn + h) * cos(B) * sin(m))**-1

a = dB * 180/pi + B
b = dL *180/pi + L

print a
print b

2 个答案:

答案 0 :(得分:8)

这不是Python:

b/a = 1 - f

答案 1 :(得分:3)

此公式中包含错误:

dB = (-dX*sin(B)*cos(L) - dY*sin(L) + dZ*cos(B) 
    + Da*(Rn * e**2*sin(B)*cos(B)/a+Df)*(Rm*(a/b)+Rn*ba)*sin(B)*cos(B))*vc**-1

应该是:

dB = (  -dX*sin(B)*cos(L) - dY*sin(B)*sin(L) + dZ*cos(B)
        + Da*(Rn * e**2*sin(B)*cos(B)/a)
        + Df*(Rm*(a/b)+Rn*b/a)*sin(B)*cos(B)  )*vc**-1