Exemplo n.º 1
0
def readRecord():
    line=122
    df = pd.read_csv("/Users/sean/Documents/Projects/Packing-Algorithm/arrangements/record.csv")
    polygons=json.loads(df["result"][line])
    for poly in polygons:
        PltFunc.addPolygon(poly)
    PltFunc.showPlt()
Exemplo n.º 2
0
 def getConvexRandom():
     polygon=[]
     num=10
     for i in range(0,num):
         # radian=(2/num)*math.pi*i+math.pi*random.randrange(0,5,1)/12 # convex 4的角度
         radian=(2/num)*math.pi*i+math.pi*random.randrange(0,3,1)/(num*2) # convex num>4的角度
         radius=random.randrange(200,500,100)
         pt=[radius*math.cos(radian),radius*math.sin(radian)]
         polygon.append(pt)
     GeoFunc.slidePoly(polygon,750,750)
     storePolygon(polygon,num=num)
     PltFunc.addPolygon(polygon)
     PltFunc.showPlt()
Exemplo n.º 3
0
 def showResult(self, **kw):
     if "current" in kw and kw["current"] == True:
         for poly in self.cur_polys:
             PltFunc.addPolygonColor(poly)
         PltFunc.addLine(
             [[0, self.new_height], [self.width, self.new_height]],
             color="blue")
     if "initial" in kw and kw["initial"] == True:
         for poly in self.polys:
             PltFunc.addPolygon(poly)
         PltFunc.addLine([[0, self.height], [self.width, self.height]],
                         color="blue")
     PltFunc.showPlt()
Exemplo n.º 4
0
 def pltArea(self):
     A, B, C = 0, 0, 0
     for i, coefficient in enumerate(self.break_points_list):
         print(coefficient)
         A = A + coefficient[1]
         B = A + coefficient[2]
         C = A + coefficient[3]
         if i > 0:
             x = [self.break_points_list[i - 1][0], coefficient[0]]
         else:
             x = [0, coefficient[0]]
         y0 = self.getQuadratic(x[0], A, B, C)
         y1 = self.getQuadratic(x[1], A, B, C)
         PltFunc.addLine([[x[0], y0], [x[1], y1]])
     PltFunc.showPlt()
Exemplo n.º 5
0
 def showAll(self):
     for i in range(0,len(self.polygons)):
         PltFunc.addPolygon(self.polygons[i])
     length=max(self.width,self.contain_height)
     PltFunc.addLine([[self.width,0],[self.width,self.contain_height]],color="blue")
     PltFunc.showPlt(width=length,height=length)
Exemplo n.º 6
0
 def showAll(self):
     for i in range(0, self.n_polys):
         PltFunc.addPolygon(self.polygons[i])
     PltFunc.showPlt()
Exemplo n.º 7
0
def readPoly():
    line=1000*10+random.randint(0,1000)
    df = pd.read_csv("/Users/sean/Documents/Projects/Packing-Algorithm/record/convex.csv")
    polygon=json.loads(df["polygon"][line])
    PltFunc.addPolygon(polygon)
    PltFunc.showPlt()