예제 #1
0
 def placeFirstPoly(self):
     '''
     放置第一个形状进去,并平移到left-bottom
     '''
     poly=self.polygons[0]
     poly_index=GeoFunc.checkTop(poly)
     left_index,bottom_index,right_index,top_index=GeoFunc.checkBound(poly)
     
     move_x=poly[left_index][0]
     move_y=poly[bottom_index][1]
     GeoFunc.slidePoly(poly,0,-move_y)
예제 #2
0
파일: data.py 프로젝트: Trixter9994/lazero
 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()
예제 #3
0
 def testGCS(self):
     # polygons=[]
     # polygons.append(self.getTestPolys()[0])
     # polygons.append(self.getTestPolys()[1])
     polygons = getData()
     num = 1  # 形状收缩
     for poly in polygons:
         for ver in poly:
             ver[0] = ver[0] * num
             ver[1] = ver[1] * num
     gcs = GCS(polygons)
     GeoFunc.slidePoly(polygons[0], 500, 500)
     gcs.showAll()
     gcs.GuidedCuckooSearch(1500, 10)
     gcs.showAll()
예제 #4
0
    def getInnerFitRectangle(self,poly):
        '''
        获得IFR,同时平移到left-bottom
        '''
        poly_index=GeoFunc.checkTop(poly)
        left_index,bottom_index,right_index,top_index=GeoFunc.checkBound(poly)
        
        move_x=poly[left_index][0]
        move_y=poly[bottom_index][1]
        GeoFunc.slidePoly(poly,-move_x,-move_y)

        refer_pt=[poly[poly_index][0],poly[poly_index][1]]
        width=self.width-poly[right_index][0]
        height=self.height-poly[top_index][1]

        IFR=[refer_pt,[refer_pt[0]+width,refer_pt[1]],[refer_pt[0]+width,refer_pt[1]+height],[refer_pt[0],refer_pt[1]+height]]
        
        return IFR