我试图计算通过椭圆焦点的半横断直肠(L)的长度(例如,图中的蓝线取自http://mathworld.wolfram.com/SemilatusRectum.html)
在哪里
L=a(1-e**2)(http://mathworld.wolfram.com/SemilatusRectum.html)
以及
e=c/a(http://mathworld.wolfram.com/Eccentricity.html)
我用python编写了这段代码来计算L,但是没有得到预期的结果。在
我的代码是:
import math
import matplotlib.pyplot as plt
a = 10 # semimajor axis
b = 5 # semiminor axis
# calculate and plot semilatus rectum
for c in range(0, a):
eccentricity = c / a
L = (a-c) * (1. - eccentricity**2)
plt.plot([0, L], [c, c])
# plot ellipse
for t in range(0, 360):
x = a*math.cos(t)
y = b*math.sin(t)
plt.scatter(b*math.cos(t), a*math.sin(t), s=1, c="r", edgecolor="none")
结果是:
#######更新多亏了@slatertyranus,我才意识到我问题中的错误
你的问题让我有点困惑,但下面是如何计算椭圆的直肠大部:
我希望这有帮助。我还不知道你想怎么处理这个情节,所以如果你还有什么问题,请告诉我。在
相关问题 更多 >
编程相关推荐