本文整理匯總了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()