本文整理汇总了Python中Polygon.Polygon.area方法的典型用法代码示例。如果您正苦于以下问题:Python Polygon.area方法的具体用法?Python Polygon.area怎么用?Python Polygon.area使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Polygon.Polygon
的用法示例。
在下文中一共展示了Polygon.area方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: fetch_grid
# 需要导入模块: from Polygon import Polygon [as 别名]
# 或者: from Polygon.Polygon import area [as 别名]
def fetch_grid((i, j)):
"""on demand generation of empty grid squares."""
(i, j) = unwrap((i, j))
if (i, j) not in grid:
xloc = i * grid_spacing
yloc = j * grid_spacing
r = Polygon(
[
(xloc, yloc),
(xloc + grid_spacing, yloc),
(xloc + grid_spacing, yloc + grid_spacing),
(xloc, yloc + grid_spacing),
]
)
p = sample.sample(r)
t = random.expovariate(r.area())
grid[i, j] = (p, t, r)
return grid[(i, j)]
示例2: __init__
# 需要导入模块: from Polygon import Polygon [as 别名]
# 或者: from Polygon.Polygon import area [as 别名]
class MPolygon:
"""
this class will eventually stop the mess with Polygon classes
"""
def __init__(self, id, points, mode='tuple', data=None):
from Polygon import Polygon as Poly
self.poly = Poly()
def __str__(self):
return '<M;Polygon ('+str(len(self.points))+' points)>'
def svgPathString(self, useInt=True):
"""
returns the path string representation of this polygon
"""
ps = ''
pts = self.points[:]
if self.closed:
pts.append(pts[0])
for pt in pts:
if pt.deleted: continue #ignore deleted points
if ps == '': ps = 'M'
else: ps += 'L'
if useInt:
ps += '%d,%d' % (round(pt.x), round(pt.y))
else:
ps += '%.3f,%.3f' % (pt.x, pt.y)
if self.closed:
ps += 'Z' # close path
return ps
def area(self):
return self.poly.area()