How to write mathematic formula in python
12,197
Solution 1
This isn't Python:
b/a = 1 - f
Solution 2
This formula has errors in it:
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
It should be:
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
Comments
-
daikini almost 2 years
I try to write these formulas in python but with no luck
I have no errors in code but I know that calculation gives incorrect result so I guess I have
something wrong in implementation of formulas.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