本文整理汇总了Python中Polygon.center方法的典型用法代码示例。如果您正苦于以下问题:Python Polygon.center方法的具体用法?Python Polygon.center怎么用?Python Polygon.center使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Polygon
的用法示例。
在下文中一共展示了Polygon.center方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: len
# 需要导入模块: import Polygon [as 别名]
# 或者: from Polygon import center [as 别名]
if country in i_country_dict.keys():
i_country_dict[country]=i_country_dict[country]+len(x_points)
i_area_dict[country]=i_area_dict[country]+i_area
else:
i_country_dict[country]=len(x_points)
i_area_dict[country]=i_area
if len(x_points)<20:
print "Dropped for too small."
continue
if len(x_points)<50:
center=i_poly.center()
if check_pop(pop_dict,center)<1.0:
print "Dropped for too few people."
continue
inter_x,inter_y=chi(x_points,y_points,lam)
new_x,new_y=linear(inter_x,inter_y,threshold)
l_area=Polygon([[new_x[i],new_y[i]] for i in range(len(new_x))]).area()
i_lam=lam
if len(x_points)>=5000:
num_thres=500
elif len(x_points)>=500:
num_thres=200
else:
示例2: __init__
# 需要导入模块: import Polygon [as 别名]
# 或者: from Polygon import center [as 别名]
#.........这里部分代码省略.........
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)
def gotoRegion(self, current_reg, next_reg, last=False):
"""
If ``last`` is True, we will move to the center of the destination region.
Returns ``True`` if we've reached the destination region.
"""
q_gBundle = [[],[]] # goal bundle
q_overlap = [[],[]] # overlapping points with robot range
pose = self.pose_handler.getPose() # Find our current configuration
#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)
if current_reg == next_reg and not last:
# No need to move!
self.drive_handler.setVelocity(0, 0) # So let's stop
return False
# Check if Vicon has cut out
if math.isnan(pose[2]):
print "WARNING: No Vicon data! Pausing."
#self.drive_handler.setVelocity(0, 0) # So let's stop
time.sleep(1)
return False
###This part is run when the robot goes to a new region, otherwise, the original map will be used.
if not self.previous_current_reg == current_reg:
print 'getting into bug alogorithm'