I am trying to write code that depicts the elliptic paths of an object using the equation for the ellipse r = a (1-e ^ 2) / (1 + e * cos (theta)). I would also like this data to be placed in an array for another use.
from numpy import *#Imports Python mathematical functions library import matplotlib.pyplot as plt #Imports plot library from pylab import * a = 5 e = 0.3 theta = 0 while theta <= 2*pi: r = (a*(1-e**2))/(1+e*cos(theta)) print("r = ",r,"theta = ",theta) plt.polar(theta, r) theta += pi/180 plt.show()
The code calculates the correct values ββfor r and theta, but the graph is empty. A polar graph window will appear, but nothing has been built.
Please, help. Thanks in advance.
source share