Python:在轨迹中添加初始和最终位置

时间:2013-05-28 00:58:58

标签: python numpy matplotlib

如何在-20度真实异常和103度真实异常位置的地块上添加标记?

我所拥有的是沿着地球周围的双曲线路径的航天器轨迹,在那里我解决了在真正的异常之间飞行所花费的时间。不幸的是,我不知道在路径上以指定角度标记位置的方法。

我知道我能做到

initial = pylab.Circle((location), radius = 10, color = '#000000')
final = ....

但是我要为位置坐标做些什么呢?有没有办法在没有蛮力方法求解坐标的情况下做到这一点?

import numpy as np
import pylab

a = -35000  #  the semi-major axis of the hyperbolic trajectory                     
e = 1.2  #  the eccentricity                                                        
nu0 = -20 * np.pi / 180  #  initial anomaly                                         
nuf = 103 * np.pi / 180  #  final anomaly                                           

F0 = 2 * np.arctanh(np.sqrt((e - 1) / (e + 1)) * np.tan(nu0 / 2))

Ff = 2 * np.arctanh(np.sqrt((e - 1) / (e + 1)) * np.tan(nuf / 2))

M0 = e * np.sinh(F0) - F0

Mf = e * np.sinh(Ff) - Ff

n = np.sqrt(398600.0 / -a ** 3)  #  the mean motion                                 

deltat = (Mf - M0) / n  #  change of time in secs                                   

hours = deltat / 3600

h = np.sqrt(a * 398600 * (1 - e ** 2))


def r(nu):
    return h ** 2 / (398600 * (1 + e * np.cos(nu)))


rt = r(nu)
ext = [np.argmin(rt), np.argmax(rt)]
rt[ext] = np.nan

nu = np.linspace(0, 2 * np.pi, 500000)

fig = pylab.figure()
ax = fig.add_subplot(111, aspect = 'equal')
earth = pylab.Circle((0, 0), radius = 6378, color = 'blue')
ax.add_patch(earth)
ax.plot(rt * np.cos(nu), rt * np.sin(nu), 'r')
pylab.axis([-70000, 10000, -40000, 40000])
pylab.show()

0 个答案:

没有答案