当前位置: 首页>>代码示例>>Python>>正文


Python Polygon.scale方法代码示例

本文整理汇总了Python中Polygon.scale方法的典型用法代码示例。如果您正苦于以下问题:Python Polygon.scale方法的具体用法?Python Polygon.scale怎么用?Python Polygon.scale使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Polygon的用法示例。


在下文中一共展示了Polygon.scale方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: Polygon

# 需要导入模块: import Polygon [as 别名]
# 或者: from Polygon import scale [as 别名]
class Solid:
    name = "solid"
    id = 0
    
    polygon = Polygon()
    material = Material()
    
    def __init__(self, points):
        self.polygon = Polygon(points)
        
    def fill(self, particles):
        xmin, xmax, ymin, ymax = self.polygon.boundingBox()
        
        d2 = 2 * self.material.d
        x = xmin
        while x < xmax:
            x += d2
            y = ymin
            while y < ymax:
                y += d2
                if self.polygon.isInside(x, y):
                    id = len(particles)
                    particles.append(self.material.createParticle(x, y, id))
                    
        pass
        
    def setInfo(self, name, id):
        self.name = name
        self.id = id
        
    def setMaterial(self, material):
        self.material = material
        
    def scaleIn(self, scale):
        self.polygon.scale(scale, scale, 0.0, 0.0)
        
    def scaleOut(self, scale):
        self.polygon.scale(1.0 / scale, 1.0 / scale, 0.0, 0.0)
        
    def points(self):
        return self.polygon[0]
    
    def len(self):
        return self.polygon.nPoints(0)
开发者ID:BackupTheBerlios,项目名称:veda-svn,代码行数:46,代码来源:Project.py

示例2: __init__

# 需要导入模块: import Polygon [as 别名]
# 或者: from Polygon import scale [as 别名]

#.........这里部分代码省略.........
        self.coordmap_lab2map = proj.coordmap_lab2map
        self.last_warning = 0

                
        ###################################
        ########used by Bug algorithm######
        ###################################



        # PARAMETERS        
        self.LeftRightFlag     = 1       # originally set to right 1- right, 0 left      
        
        # Pioneer related parameters
        self.PioneerWidthHalf  = 0.20     # (m) width of Pioneer
        self.PioneerLengthHalf = 0.25     # (m) lenght of Pioneer
        self.ratioBLOW         = 0.5      # blow up ratio of the pioneer box                             ######### 5 BOX
        self.PioneerBackMargin=  self.ratioBLOW*self.PioneerLengthHalf*2    # (in m)
        
        self.range             = 0.75     # (m) specify the range of the robot (when the normal circle range cannot detect obstacle)
        self.obsRange          = 0.50     # (m) range that says the robot detects obstacles
        #self.shift             = 0.20     # 0.15

        
        ## 2: 0DE
        self.factorODE = 50
        if  self.system == 2:
            self.PioneerWidthHalf  = self.PioneerWidthHalf*self.factorODE    
            self.PioneerLengthHalf = self.PioneerLengthHalf*self.factorODE    
            self.range             = self.range*self.factorODE   
            self.obsRange          = self.obsRange*self.factorODE
            self.PioneerBackMargin= self.PioneerBackMargin*self.factorODE
            

        #build self.map with empty contour
        self.map = Rectangle (1,1)   
        self.map -= self.map          #Polygon built from the original map

        #build self.ogr with empty contour
        self.ogr = Rectangle (1,1)   #Polygon built from occupancy grid data points
        self.ogr -= self.ogr
      
        self.freespace = None               # contains only the boundary
        self.map_work  = None               # working copy of the map. remove current region and next region
        self.previous_current_reg = None    # previous current region   
        self.currentRegionPoly  = None      # current region's polygon
        self.nextRegionPoly    = None       # next region's polygon
        self.q_g               = [0,0]      # goal point of the robot heading to 
        self.q_hit             = [0,0]      # location where the robot first detect an obstacle
        self.boundary_following= False      # tracking whether it is in boundary following mode
        self.m_line            = None       # m-line polygon
        self.trans_matrix      = mat([[0,1],[-1,0]])   # transformation matrix for find the normal to the vector connecting a point on the obstacle to the robot
        #self.corr_theta        = pi/6
        #self.corr_matrix       = mat([[cos(self.corr_theta),-sin(self.corr_theta)],[sin(self.corr_theta),cos(self.corr_theta)]])
        self.q_hit_count       = 0
        self.q_hit_Thres       = 1000
        self.prev_follow       = [[],[]]
        
        
        ## Construct robot polygon (for checking overlap)
        pose = self.pose_handler.getPose()
        self.prev_pose = pose        
        self.robot = Rectangle(self.obsRange*3,self.PioneerBackMargin)    
        self.robot.shift(pose[0]-self.obsRange,pose[1]-2*self.PioneerLengthHalf)
        self.robot = Circle(self.obsRange,(pose[0],pose[1])) - self.robot
        self.robot.rotate(pose[2]-pi/2,pose[0],pose[1]) 
        self.robot.shift(self.shift*cos(pose[2]),self.shift*sin(pose[2]))
        
        #construct real robot polygon( see if there is overlaping with path to goal
        self.realRobot = Rectangle(self.PioneerWidthHalf*2.5,self.PioneerLengthHalf*2 )
        self.realRobot.shift(pose[0]-self.PioneerWidthHalf*1.25,pose[1]-self.PioneerLengthHalf*1)
        self.realRobot.rotate(pose[2]-pi/2,pose[0],pose[1]) 
                      
        #constructing map with all the regions included           
        for region in self.rfi.regions: 
            if region.name.lower()=='freespace':
                pointArray = [x for x in region.getPoints()]
                pointArray = map(self.coordmap_map2lab, pointArray)
                regionPoints = [(pt[0],pt[1]) for pt in pointArray]
                freespace    = Polygon(regionPoints)
                freespace_big= Polygon(regionPoints)                
                freespace_big.scale(1.2, 1.2)
                self.freespace = freespace_big -freespace
                self.map += freespace_big -freespace               #without including freespace

            else:
                pointArray = [x for x in region.getPoints()]
                pointArray = map(self.coordmap_map2lab, pointArray)
                regionPoints = [(pt[0],pt[1]) for pt in pointArray]
                self.map +=  Polygon(regionPoints)  

                
        #Plot the robot on the map in figure 1
        if self.PLOT == True:
            plt.figure(self.original_figure)
            plt.clf()            
            self.plotPoly(self.realRobot, 'r')
            self.plotPoly(self.robot, 'b')
            plt.plot(pose[0],pose[1],'bo')
            self.plotPioneer(self.original_figure)
开发者ID:SMSmith,项目名称:LTLMoP,代码行数:104,代码来源:BugController.py


注:本文中的Polygon.scale方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。