示例#1
0
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")
otr_s = ((-3, 3), (3, 3))
line_1 = dl(otr_s[0][0], otr_s[0][1], otr_s[1][0], otr_s[1][1])
line_2 = dl(otr_s[0][0], otr_s[0][1], otr_s[1][0] - 8, otr_s[1][1] - 8)
#lrand, rrand = rd.randint(-8, -1), rd.randint(1, 8)
lrand, rrand = -1, 1
rp_1, rp_2 = (lrand, get_y(lrand, line_2)), (rrand, get_y(rrand, line_2))
point_1 = ((lrand + rrand) / 2, get_y((lrand + rrand) / 2, line_2))
otr_1 = ((otr_s[0][0], point_1[0]), (otr_s[1][0], point_1[1]))
otr_2 = ((otr_s[0][1], rp_1[0]), (otr_s[1][1], rp_1[1]))
point_2 = intrs(otr_1, otr_2)
line_3 = dl(rp_2[0], point_2[0], rp_2[1], point_2[1])
point_3 = intrs(line_1, line_3)
data.write("l " + str(line_1) + '\n')
data.write("o " + str(otr_s) + '\n')
data.write("l " + str(line_2) + '\n')
data.write("p " + str(rp_1) + '\n' + "p " + str(rp_2) + '\n' + "p " +
           str(point_1) + '\n')
data.write("o " + str(otr_1) + '\n' + "o " + str(otr_2) + '\n')
data.write("p " + str(point_2) + '\n')
data.write("l " + str(line_3) + '\n')
data.write("p " + str(point_3) + '\n')
data.write("p " + str((otr_s[0][1], otr_s[1][1])) + '\n')
data.close()
fig = opt.figure()
AnI = animation.FuncAnimation(fig, animate, interval=1000)
opt.xlim(-10, 10)
opt.ylim(-10, 10)
示例#2
0
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)
示例#3
0
import matplotlib.pyplot as opt, matplotlib.animation as animation, pathlib, random as rd
from Main import dl, intrs, animate, get_y, cl_int

data = open(str(pathlib.Path(__file__).parent.absolute()) + "\Data.txt", "w")
circle_s = (0, 0, 5)
otr_s = ((circle_s[0] + circle_s[2], circle_s[0] - circle_s[2]), (circle_s[1],
                                                                  circle_s[1]))
rp = (0, 3)
line_1 = dl(otr_s[0][0], rp[0], otr_s[1][0], rp[1])
line_2 = dl(otr_s[0][1], rp[0], otr_s[1][1], rp[1])
point_1, point_2 = cl_int(circle_s, line_2,
                          otr_s[0][1]), cl_int(circle_s, line_1, otr_s[0][0])
line_3 = dl(otr_s[0][0], point_1[0], otr_s[1][0], point_1[1])
line_4 = dl(otr_s[0][1], point_2[0], otr_s[1][1], point_2[1])
point_3 = intrs(line_3, line_4)
line_5 = dl(rp[0], point_3[0], rp[1], point_3[1])
data.write("c " + str(circle_s) + '\n')
data.write("o " + str(otr_s) + '\n')
data.write("p " + str(rp) + '\n')
data.write("l " + str(line_2) + '\n' + "l " + str(line_1) + '\n')
data.write("p " + str(point_1) + '\n' + "p " + str(point_2) + '\n')
data.write("l " + str(line_4) + '\n' + "l " + str(line_3) + '\n')
data.write("p " + str(point_3) + '\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()
示例#4
0
import matplotlib.pyplot as opt, matplotlib.animation as animation, pathlib
from Main import dl, intrs, animate

data = open(str(pathlib.Path(__file__).parent.absolute())+"\Data.txt","w")
otr_s, rp = ((-5, 5), (3, 3)), (0, -7)
line = dl(otr_s[0][0], otr_s[0][1], otr_s[1][0]-8, otr_s[1][1]-8)
otr_1 = ((rp[0], otr_s[0][0]), (rp[1], otr_s[1][0]))
otr_2 = ((rp[0], otr_s[0][1]), (rp[1], otr_s[1][1]))
point_1, point_2 = intrs(otr_1, line), intrs(otr_2, line)
otr_3 = ((point_1[0], otr_s[0][1]), (point_1[1], otr_s[1][1]))
otr_4 = ((point_2[0], otr_s[0][0]), (point_2[1], otr_s[1][0]))
point_3 = intrs(otr_3, otr_4)
line_2 = dl(rp[0], point_3[0], rp[1], point_3[1])
point_r = intrs(otr_s, line_2)
data.write("o "+str(otr_s)+'\n')
data.write("l "+str(line)+'\n')
data.write("p "+str(rp)+'\n')
data.write("o "+str(otr_1)+'\n')
data.write("o "+str(otr_2)+'\n')
data.write("p "+str(point_1)+'\n'+"p "+str(point_2)+'\n')
data.write("o "+str(otr_3)+'\n'+"o "+str(otr_4)+'\n')
data.write("p "+str(point_3)+'\n')
data.write("l "+str(line_2)+'\n')
data.write("p "+str(point_r)+'\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()
示例#5
0
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")
otr_s = ((-5, 5), (3, 3))
line_1 = dl(otr_s[0][0], otr_s[0][1], otr_s[1][0], otr_s[1][1])
line_2 = dl(otr_s[0][0], otr_s[0][1], otr_s[1][0]-8, otr_s[1][1]-8)
#lrand, rrand = rd.uniform(-1, -0.5), rd.uniform(0.5, 1)
lrand, rrand = -0.7, 0.7
rp_1, rp_2 = (lrand, get_y(lrand, line_2)), (rrand, get_y(rrand, line_2))
len_CD = rrand-lrand
point_exl, point_exr = (lrand-len_CD, get_y(lrand-len_CD, line_2)), (rrand+len_CD, get_y(lrand+len_CD, line_2))
point_exl_2, point_exr_2 = (lrand-2*len_CD, get_y(lrand-2*len_CD, line_2)), (rrand+2*len_CD, get_y(lrand+2*len_CD, line_2))
otr_1 = ((otr_s[0][0], point_exr_2[0]), (otr_s[1][0], point_exr_2[1]))
otr_2 = ((otr_s[0][1], point_exl_2[0]), (otr_s[1][1], point_exl_2[1]))
point_1 = intrs(otr_1, otr_2)
line_3 = dl(point_exl[0], point_1[0], point_exl[1], point_1[1])
line_4 = dl(rp_1[0], point_1[0], rp_1[1], point_1[1])
line_5 = dl(rp_2[0], point_1[0], rp_2[1], point_1[1])
line_6 = dl(point_exr[0], point_1[0], point_exr[1], point_1[1])
point_2, point_3, point_4, point_5 = intrs(otr_s, line_6), intrs(otr_s, line_5), intrs(otr_s, line_4), intrs(otr_s, line_3)
#data.write("l "+str(line_1)+'\n')
data.write("o "+str(otr_s)+'\n')
data.write("l "+str(line_2)+'\n')
data.write("p "+str(rp_1)+'\n'+"p "+str(rp_2)+'\n')
data.write("p "+str(point_exl)+'\n'+"p "+str(point_exl_2)+'\n')
data.write("p "+str(point_exr)+'\n'+"p "+str(point_exr_2)+'\n')
data.write("o "+str(otr_1)+'\n'+"o "+str(otr_2)+'\n')
data.write("p "+str(point_1)+'\n')
data.write("l "+str(line_3)+'\n'+"l "+str(line_4)+'\n'+"l "+str(line_5)+'\n'+"l "+str(line_6)+'\n')
data.write("p "+str(point_2)+'\n'+"p "+str(point_3)+'\n'+"p "+str(point_4)+'\n'+"p "+str(point_5)+'\n')