本文整理汇总了Python中Polygon.isInside方法的典型用法代码示例。如果您正苦于以下问题:Python Polygon.isInside方法的具体用法?Python Polygon.isInside怎么用?Python Polygon.isInside使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Polygon
的用法示例。
在下文中一共展示了Polygon.isInside方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: Polygon
# 需要导入模块: import Polygon [as 别名]
# 或者: from Polygon import isInside [as 别名]
class Domen:
id = 0
polygon = Polygon()
def __init__(self, points, id=0):
self.polygon = Polygon(points)
def contains(self, point):
return self.polygon.isInside(point.x, point.y) == 1
示例2: range
# 需要导入模块: import Polygon [as 别名]
# 或者: from Polygon import isInside [as 别名]
minlat=1000000
maxlon=-1000000
minlon=1000000
for point in poly:
lat=point[0]
lon=point[1]
if lat>maxlat: maxlat=lat
if lat<minlat: minlat=lat
if lon>maxlon: maxlon=lon
if lon<minlon: minlon=lon
lat_values=[minlat+1.0/24*i for i in range(int((maxlat-minlat)*24))]
lon_values=[minlon+1.0/24*i for i in range(int((maxlon-minlon)*24))]
for lat in lat_values:
for lon in lon_values:
if i_poly.isInside(lat,lon):
fill_points.append((lat,lon))
if len(fill_points)==0: continue
for point in fill_points:
dens=float(check_pop(point))
#print dens
#print point,dens,peak_dense,best_point
if dens>peak_dense:
peak_dense=dens
best_point=point
"""
x=[p[0] for p in fill_points]
y=[p[1] for p in fill_points]
pylab.plot(x,y,"*")
示例3: __init__
# 需要导入模块: import Polygon [as 别名]
# 或者: from Polygon import isInside [as 别名]
#.........这里部分代码省略.........
#set to zero velocity before finding the tranFace
self.drive_handler.setVelocity(0, 0)
if last:
transFace = None
else:
print "Current reg is " + str(self.rfi.regions[current_reg].name.lower())
print "Next reg is "+ str(self.rfi.regions[next_reg].name.lower())
for i in range(len(self.rfi.transitions[current_reg][next_reg])):
pointArray_transface = [x for x in self.rfi.transitions[current_reg][next_reg][i]]
transFace = asarray(map(self.coordmap_map2lab,pointArray_transface))
bundle_x = (transFace[0,0] +transFace[1,0])/2 #mid-point coordinate x
bundle_y = (transFace[0,1] +transFace[1,1])/2 #mid-point coordinate y
q_gBundle = hstack((q_gBundle,vstack((bundle_x,bundle_y))))
q_gBundle = q_gBundle.transpose()
# Find the closest face to the current position
max_magsq = 1000000
for tf in q_gBundle:
magsq = (tf[0] - pose[0])**2 + (tf[1] - pose[1])**2
if magsq < max_magsq:
pt1 = tf
max_magsq = magsq
transFace = 1
self.q_g[0] = pt1[0]
self.q_g[1] = pt1[1]
# Push the goal point to somewhere inside the next region to ensure the robot will go there.
if self.rfi.regions[current_reg].name.lower()=='freespace':
self.q_g = self.q_g+(self.q_g-asarray(self.nextRegionPoly.center()))/norm(self.q_g-asarray(self.nextRegionPoly.center()))*3*self.PioneerLengthHalf
if not self.nextRegionPoly.isInside(self.q_g[0],self.q_g[1]):
self.q_g = self.q_g-(self.q_g-asarray(self.nextRegionPoly.center()))/norm(self.q_g-asarray(self.nextRegionPoly.center()))*6*self.PioneerLengthHalf
else:
self.q_g = self.q_g+(self.q_g-asarray(self.currentRegionPoly.center()))/norm(self.q_g-asarray(self.currentRegionPoly.center()))*3*self.PioneerLengthHalf
if self.currentRegionPoly.isInside(self.q_g[0],self.q_g[1]):
self.q_g = self.q_g-(self.q_g-asarray(self.currentRegionPoly.center()))/norm(self.q_g-asarray(self.currentRegionPoly.center()))*6*self.PioneerLengthHalf
#plot exiting point
if self.PLOT_EXIT == True:
plt.figure(self.overlap_figure)
plt.clf()
plt.plot(q_gBundle[:,0],q_gBundle[:,1],'ko' )
plt.plot(self.q_g[0],self.q_g[1],'ro')
plt.plot(pose[0],pose[1],'bo')
self.plotPioneer(self.overlap_figure,1)
if transFace is None:
print "ERROR: Unable to find transition face between regions %s and %s. Please check the decomposition (try viewing projectname_decomposed.regions in RegionEditor or a text editor)." % (self.rfi.regions[current_reg].name, self.rfi.regions[next_reg].name)
##################################################
#######check whether obstacle is detected#########
##################################################
#Update pose,update self.robot, self.realRobot orientation
self.robot.shift(pose[0]-self.prev_pose[0],pose[1]-self.prev_pose[1])
self.realRobot.shift(pose[0]-self.prev_pose[0],pose[1]-self.prev_pose[1])
self.robot.rotate(pose[2]-self.prev_pose[2],pose[0],pose[1])
self.realRobot.rotate(pose[2]-self.prev_pose[2],pose[0],pose[1])
self.prev_pose = pose
############################
########### STEP 1##########
示例4: range
# 需要导入模块: import Polygon [as 别名]
# 或者: from Polygon import isInside [as 别名]
lat=point[0]
lon=point[1]
if lat>maxlat: maxlat=lat
if lat<minlat: minlat=lat
if lon>maxlon: maxlon=lon
if lon<minlon: minlon=lon
maxlat=maxlat+0.1*abs(maxlat-minlat)
minlat=minlat-0.1*abs(maxlat-minlat)
maxlon=maxlon+0.1*abs(maxlon-minlon)
minlon=minlon-0.1*abs(maxlon-minlon)
lat_values=[minlat+(maxlat-minlat)*1.0/density*i for i in range(density+1)]
lon_values=[minlon+(maxlon-minlon)*1.0/density*i for i in range(density+1)]
#print lat_values,lon_values
for lat in lat_values:
for lon in lon_values:
if not i_poly.isInside(lat,lon):
fill_points.append((lat,lon))
points=points+fill_points
points=[Point_2(point[0],point[1]) for point in points]
elif instr=="a":
alpha=raw_input("Enter an alpha value: ")
try:
test=float(alpha)
except ValueError:
print "Invalid input for alpha value."
continue
alpha_faces=test_Alpha_shapes_2(points,alpha)
alpha_edges=[["%s:%s:" %(face.source().x(),face.source().y()),"%s:%s:" %(face.target().x(),face.target().y())] for face in alpha_faces]