本文整理汇总了Python中shapely.geometry.Polygon.__init__方法的典型用法代码示例。如果您正苦于以下问题:Python Polygon.__init__方法的具体用法?Python Polygon.__init__怎么用?Python Polygon.__init__使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类shapely.geometry.Polygon
的用法示例。
在下文中一共展示了Polygon.__init__方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: set
# 需要导入模块: from shapely.geometry import Polygon [as 别名]
# 或者: from shapely.geometry.Polygon import __init__ [as 别名]
def set(self, center, northern_most_unit_vector_direction, side_length, parent, depth=None):
# The Hexagon class is a representation of a 2D planar hexagon,
# represented in Cartesian coordinates of the center and all vertices.
#
# center := an absolute point, as a 2D numpy column vector, representing
# the center of hexagon in a Cartesian coordinate system.
#
# northern_most_vertex_direction := a free unit vector, as a 2D numpy
# column vector, indicating the direction of the northern-most vertex.
#
# side_length := a scalar representing the length of any side of the
# resulting hexagon.
self.initialized = True
if depth is not None:
self.depth = depth
self.center = center.copy()
self.north_unit_dir = northern_most_unit_vector_direction.copy()
self.side_length = side_length
scaled_north_dir = side_length * northern_most_unit_vector_direction
north = scaled_north_dir + self.center
# From the center point and the north vertex, we can compute the other
# vertices of the hexagon. Each vertex, relative to the center, is
# simply the previous vector rotated by 60 degrees (pi/3 radians).
# Perform this rotation five times to calculate the direction of all
# six hexagon vertices.
self.vertex_directions = [scaled_north_dir]
self.vertices = [north]
for i in range(5):
prev_direction = self.vertex_directions[-1]
rotated_direction = rotate_60 * prev_direction
self.vertex_directions.append(rotated_direction)
# Calculate Cartesian coordinates of vertex.
vertex = rotated_direction + self.center
self.vertices.append(vertex)
self.north_dir,\
self.northeast_dir,\
self.southeast_dir,\
self.south_dir,\
self.southwest_dir,\
self.northwest_dir = self.vertex_directions
self.north_vertex,\
self.northeast_vertex,\
self.southeast_vertex,\
self.south_vertex,\
self.southwest_vertex,\
self.northwest_vertex = self.vertices
Polygon.__init__(self, self.vertices)
# The following member variables correspond to points to neighboring
# hexagons related to the topological relationship between this hexagon
# and neighboring hexagons.
self.neighboring_hexagons = [None for i in range(6)]
self.internal_hexagons = [None for i in range(7)]
self.parent = parent
示例2: __init__
# 需要导入模块: from shapely.geometry import Polygon [as 别名]
# 或者: from shapely.geometry.Polygon import __init__ [as 别名]
def __init__(self, x, y, width, height, rotation, visible):
self.x = x
self.y = y
self.width = width
self.height = height
self.rotation = rotation
self.visible = visible
w2 = width / 2.
h2 = height / 2.
l = []
for k in range(4):
l.append(rotate((mx[k] * w2, my[k] * h2), rotation))
l = [(a[0] + x, a[1] + y) for a in l]
Polygon.__init__(self, l)
示例3: __init__
# 需要导入模块: from shapely.geometry import Polygon [as 别名]
# 或者: from shapely.geometry.Polygon import __init__ [as 别名]
def __init__(self, poly_points):
Polygon.__init__(self, poly_points)
示例4: __init__
# 需要导入模块: from shapely.geometry import Polygon [as 别名]
# 或者: from shapely.geometry.Polygon import __init__ [as 别名]
def __init__(self, tid, points):
Polygon.__init__(self, points)
self.tid = tid
示例5: __init__
# 需要导入模块: from shapely.geometry import Polygon [as 别名]
# 或者: from shapely.geometry.Polygon import __init__ [as 别名]
def __init__(self, minx, miny, maxx, maxy):
minx = float(minx)
miny = float(miny)
maxx = float(maxx)
maxy = float(maxy)
Polygon.__init__(self, [(minx, miny), (minx, maxy), (maxx, maxy), (maxx, miny)])