-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathL_4.py
More file actions
33 lines (32 loc) · 1.42 KB
/
Copy pathL_4.py
File metadata and controls
33 lines (32 loc) · 1.42 KB
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
import matplotlib.pyplot as opt, matplotlib.animation as animation, pathlib, random as rd
from Main import dl, intrs, animate, get_y
data = open(str(pathlib.Path(__file__).parent.absolute())+"\Data.txt","w")
point_s = (0, 5)
otr_s = ((-5, 5), (-5, -5))
line_1 = dl(otr_s[0][0], otr_s[0][1], otr_s[1][0]+8, otr_s[1][1]+8)
line_2 = dl(otr_s[0][0], otr_s[0][1], otr_s[1][0], otr_s[1][1])
point_1 = ((otr_s[0][0]+otr_s[0][1])/2, get_y((otr_s[0][0]+otr_s[0][1])/2, line_2))
otr_1 = ((point_s[0], point_1[0]), (point_s[1], point_1[1]))
otr_2 = ((point_s[0], otr_s[0][0]), (point_s[1], otr_s[1][0]))
point_2, point_3 = intrs(otr_1, line_1), intrs(otr_2, line_1)
line_3 = dl(point_1[0], point_3[0], point_1[1], point_3[1])
line_4 = dl(otr_s[0][1], point_2[0], otr_s[1][1], point_2[1])
point_4 = intrs(line_3, line_4)
line_5 = dl(point_4[0], point_s[0], point_4[1], point_s[1])
data.write("l "+str(line_1)+'\n')
data.write("p "+str(point_s)+'\n')
data.write("l "+str(line_2)+'\n')
data.write("o "+str(otr_s)+'\n')
data.write("p "+str(point_1)+'\n')
data.write("o "+str(otr_2)+'\n'+"o "+str(otr_1)+'\n')
data.write("p "+str(point_3)+'\n'+"p "+str(point_2)+'\n')
data.write("l "+str(line_3)+'\n'+"l "+str(line_4)+'\n')
data.write("p "+str(point_4)+'\n')
data.write("l "+str(line_5)+'\n')
data.close()
fig = opt.figure()
AnI = animation.FuncAnimation(fig, animate, interval=1000)
opt.xlim(-10, 10)
opt.ylim(-10, 10)
opt.grid()
opt.show()