如何在停止点连接两个图?我有一个关于不连续点的等式。
import numpy as np
import pylab
r1 = 1 # AU Earth
r2 = 1.524 # AU Mars
deltanu = 75 * np.pi / 180 # angle in radians
mu = 38.86984154054163
c = np.sqrt(r1 ** 2 + r2 ** 2 - 2 * r1 * r2 * np.cos(deltanu))
s = (r1 + r2 + c) / 2
am = s / 2
def f(a):
alpha = 2 * np.arcsin(np.sqrt(s / (2 * a)))
beta = 2 * np.arcsin(np.sqrt((s - c) / (2 * a)))
return (np.sqrt(a **3 / mu) * (alpha - beta - (np.sin(alpha)
- np.sin(beta))))
def g(a):
alphag = 2* np.pi - 2 * np.arcsin(np.sqrt(s / (2 * a)))
betag = -2 * np.arcsin(np.sqrt((s - c) / (2 * a)))
return (np.sqrt(a ** 3 / mu)
* (alphag - betag - (np.sin(alphag) - np.sin(betag))))
a = np.linspace(am, 2, 500000)
fig = pylab.figure()
ax = fig.add_subplot(111)
ax.plot(a, f(a), color = '#000000')
ax.plot(a, g(a), color = '#000000')
pylab.xlim((0.9, 2))
pylab.ylim((0, 2))
pylab.show()
反映这一点的等式是:dt = np.sqrt(s ** 3 / 8) * (np.pi - betam + np.sin(betam))
其中betam = 2 * np.arcsin(np.sqrt(1 - c / s))
所以dt = 0.5
位于a = s / 2
。然而,这些图之间的差距看起来比一个点大。
我补充说:ax.plot([am, am], [.505, .55], color = '#000000')
填补了空白,但感觉不合适。
答案 0 :(得分:2)
似乎您应该只为betag
使用一个值:
import numpy as np
import matplotlib.pyplot as plt
r1 = 1 # AU Earth
r2 = 1.524 # AU Mars
deltanu = 75 * np.pi / 180 # angle in radians
mu = 38.86984154054163
c = np.sqrt(r1 ** 2 + r2 ** 2 - 2 * r1 * r2 * np.cos(deltanu))
s = (r1 + r2 + c) / 2
am = s / 2
def g(a, alphag, betag):
return (np.sqrt(a ** 3 / mu)
* (alphag - betag - (np.sin(alphag) - np.sin(betag))))
a = np.linspace(am, 2, 500000)
fig, ax = plt.subplots()
alphag = 2 * np.pi - 2 * np.arcsin(np.sqrt(s / (2 * a)))
betag = 2 * np.arcsin(np.sqrt((s - c) / (2 * a)))
ax.plot(a, g(a, alphag, betag), color = 'r')
alphag = 2 * np.arcsin(np.sqrt(s / (2 * a)))
ax.plot(a, g(a, alphag, betag), color = 'r')
plt.show()
产量
我真的不知道这里发生了什么;我偶然发现了这一点。
答案 1 :(得分:2)
ax.plot([am,am],[f(am),g(am)],color== '#000000')