-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathconics6.py
87 lines (55 loc) · 1.54 KB
/
conics6.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
import numpy as np
import matplotlib.pyplot as plt
import math
a=3
b=2
n=9
an=a/(2**(n-1))
print(an)
bn=((3**(1/2)/2)**(n-1))*b
print(bn)
len=100
theta=np.linspace(0,2*np.pi,len)
y_n = np.zeros((2,len))
O=np.array([0,0])
if(an>bn):
e_n=(1-bn**2/an**2)**(1/2)
l_n=2*(bn**2)/an
print(l_n)
y_n[0,:] = an*np.cos(theta)
y_n[1,:] = bn*np.sin(theta)
F_n1=np.array([an*e_n,0])
F_n2=-F_n1
plt.plot(y_n[0,:],y_n[1,:],label='E\N{SUBSCRIPT NINE}')
plt.plot(O[0], O[1], 'o')
plt.text(O[0] * (1 - 0.1), O[1] * (1 + 0.1) , 'O')
plt.plot(F_n1[0], F_n1[1], 'o')
plt.plot(F_n1[0], F_n1[1], 'o')
plt.text(F_n1[0] * (1 - 0.1), F_n1[1] * (1 + 0.1) , 'F\N{SUBSCRIPT ONE}')
plt.plot(F_n2[0], F_n2[1], 'o')
plt.text(F_n2[0] * (1 - 0.1), F_n2[1] * (1 + 0.1) , 'F\N{SUBSCRIPT TWO}')
if(bn>an):
e_n=(1-an**2/bn**2)**(1/2)
l_n=2*(an**2)/bn
print(l_n)
y_n[0,:] = an*np.cos(theta)
y_n[1,:] = bn*np.sin(theta)
F_n1=np.array([0,bn*e_n])
F_n2=-F_n1
plt.plot(y_n[0,:],y_n[1,:],label='E\N{SUBSCRIPT NINE}')
plt.plot(O[0], O[1], 'o')
plt.text(O[0] * (1 - 0.1), O[1] * (1 + 0.1) , 'O')
plt.plot(F_n1[0], F_n1[1], 'o')
plt.plot(F_n1[0], F_n1[1], 'o')
plt.text(F_n1[0] * (1 - 0.1), F_n1[1] * (1 + 0.1) , 'F\N{SUBSCRIPT ONE}')
plt.plot(F_n2[0], F_n2[1], 'o')
plt.text(F_n2[0] * (1 - 0.1), F_n2[1] * (1 + 0.1) , 'F\N{SUBSCRIPT TWO}')
if(l_n==1/6):
print("Length of latus rectum is 1/6")
else:
print("Length of latus rectum is " +str(l_n) )
plt.axis('equal')
plt.xlabel('$x$');plt.ylabel('$y$')
plt.legend(loc='best')
plt.grid()
plt.show()