我正在尝试实现维基百科上描述的文森蒂逆问题HERE http://en.wikipedia.org/wiki/Vincenty%27s_formulae#Inverse_problem
问题在于 lambda 根本不收敛。如果我尝试迭代公式序列,该值将保持不变,而且我真的不确定为什么。也许我只是对一个明显的问题视而不见。
应该指出的是,我是 Python 新手,仍在学习该语言,因此我不确定是否滥用该语言可能导致问题,或者我执行的某些计算中是否确实存在一些错误。我似乎找不到公式中的任何错误。
基本上,我已经以尽可能接近 wiki 文章的格式编写了代码,结果是这样的:
import math
# Length of radius at equator of the ellipsoid
a = 6378137.0
# Flattening of the ellipsoid
f = 1/298.257223563
# Length of radius at the poles of the ellipsoid
b = (1 - f) * a
# Latitude points
la1, la2 = 10, 60
# Longitude points
lo1, lo2 = 5, 150
# For the inverse problem, we calculate U1, U2 and L.
# We set the initial value of lamb = L
u1 = math.atan( (1 - f) * math.tan(la1) )
u2 = math.atan( (1 - f) * math.tan(la2) )
L = (lo2 - lo1) * 0.0174532925
lamb = L
while True:
sinArc = math.sqrt( math.pow(math.cos(u2) * math.sin(lamb),2) + math.pow(math.cos(u1) * math.sin(u2) - math.sin(u1) * math.cos(u2) * math.cos(lamb),2) )
cosArc = math.sin(u1) * math.sin(u2) + math.cos(u1) * math.cos(u2) * math.cos(lamb)
arc = math.atan2(sinArc, cosArc)
sinAzimuth = ( math.cos(u1) * math.cos(u2) * math.sin(lamb) ) // ( sinArc )
cosAzimuthSqr = 1 - math.pow(sinAzimuth, 2)
cosProduct = cosArc - ((2 * math.sin(u1) * math.sin(u2) ) // (cosAzimuthSqr))
C = (f//16) * cosAzimuthSqr * (4 + f * (4 - 3 * cosAzimuthSqr))
lamb = L + (1 - C) * f * sinAzimuth * ( arc + C * sinArc * ( cosProduct + C * cosArc * (-1 + 2 * math.pow(cosProduct, 2))))
print(lamb)
如前所述,问题是“羔羊”(lambda) 值不会变小。我什至尝试将我的代码与其他实现进行比较,但它们看起来几乎相同。
我在这里做错了什么? :-)
谢谢你们!