In [22]:
%matplotlib inline
import matplotlib.pyplot as plt
import numpy as np
theta = np.arange(-1.7,1.7,0.1)
In [23]:
r = lambda x: 2.0/(1+np.cos(x))
In [24]:
theta
Out[24]:
In [25]:
rho =r(theta)
rho
Out[25]:
In [26]:
## primeiro vou tentar um grafico polar
ax=plt.subplot(111,projection='polar')
ax.plot(theta,rho)
Out[26]:
In [27]:
ponto = lambda x: [r(x)*np.cos(x) , r(x)*np.sin(x)]
par = ponto(theta)
In [28]:
ax2=plt.subplot(111)
plt.grid()
ax2.plot(par[0],par[1])
ax2.plot([2,2],[-2,2])
ax2.plot([0,0], "ro")
ax2.set_aspect('equal')
plt.xlim(-1,4)
plt.savefig('conica3.png', format='png')
In [29]:
## O outro é uma elipse
theta1=np.arange(0,6.5,0.05)
r1=lambda x: 3/(1+0.5*np.cos(x))
ax3=plt.subplot(111,projection="polar")
ax3.plot(theta1,r1(theta1))
Out[29]:
In [30]:
## Em coordenadas cartesianas outra vez
ponto1 = lambda x: [r1(x)*np.cos(x),r1(x)*np.sin(x)]
elipse = ponto1(theta1)
In [31]:
ax4=plt.subplot(111)
plt.grid()
ax4.plot(elipse[0],elipse[1])
ax4.plot([6,6],[-3,3])
ax4.plot([0],[0], "ro")
ax4.set_aspect('equal')
plt.savefig('conica4.png',format="png")
In [ ]: