25 from ._geom
import Polygon
31 return f
"{self.__class__.__name__}({[p for p in self.getVertices()]})"
34 return self.__class__, (self.
getVerticesgetVertices(),)
37 """Iterator over vertices"""
42 return [pt
for pt
in self][i]
48 """point in polygon?"""
51 def display(self, xy0=None, frame=1, ctype=None):
52 """Display polygon on existing frame"""
56 disp = afwDisplay.Display(frame=frame)
57 with disp.Buffering():
58 for p1, p2
in self.
getEdgesgetEdges():
59 disp.line((p1 - xy0, p2 - xy0), ctype=ctype)
61 def plot(self, axes=None, **kwargs):
62 """Plot polygon with matplotlib
66 axes : `matplotlib.axes.Axes`
67 Matplotlib axes to use, or None
69 Additional arguments to `matplotlib.axes.Axes.plot`
70 or `matplotlib.axes.Axes.scatter`.
74 axes : `matplotlib.axes.Axes`
75 The axes used to make the plot (same as ``axes``, if provided).
79 import matplotlib.pyplot
as plt
82 for p1, p2
in self.
getEdgesgetEdges():
83 x = (p1.getX(), p2.getX())
84 y = (p1.getY(), p2.getY())
85 axes.plot(x, y, **kwargs)
87 x = numpy.array([p[0]
for p
in vertices])
88 y = numpy.array([p[1]
for p
in vertices])
89 axes.scatter(x, y, **kwargs)
std::vector< std::pair< Point, Point > > getEdges() const
Get vector of edges.
def display(self, xy0=None, frame=1, ctype=None)
size_t getNumEdges() const
Return number of edges.
def __contains__(self, point)
std::vector< Point > getVertices() const
Get vector of vertices.
bool contains(Point const &point) const
Returns whether the polygon contains the point.
def plot(self, axes=None, **kwargs)