# HG changeset patch # User Nicolas Saunier # Date 1259367372 18000 # Node ID 5a21d2cfee44c1aecec6f9ecabe9feeccda2db41 # Parent ef35d5f111e4701a71b45d9d1d6275dcebdb97af added polygon plotting diff -r ef35d5f111e4 -r 5a21d2cfee44 python/moving.py --- a/python/moving.py Fri Nov 27 00:21:18 2009 -0500 +++ b/python/moving.py Fri Nov 27 19:16:12 2009 -0500 @@ -121,6 +121,11 @@ # return sqrt(sq) return [hypot(x,y) for x,y in zip(self.positions[0], self.positions[1])] + def getTrajectoryInPolygon(self, polygon): + 'Returns the set of points inside the polygon' + # use shapely polygon contains + pass + class MovingObject(STObject): '''Class for moving objects i.e. with a trajectory and a geometry (volume) diff -r ef35d5f111e4 -r 5a21d2cfee44 python/utils.py --- a/python/utils.py Fri Nov 27 00:21:18 2009 -0500 +++ b/python/utils.py Fri Nov 27 19:16:12 2009 -0500 @@ -85,6 +85,14 @@ def printPoint(x,y): return '(%f,%f)'%(x,y) +def plotPolygon(poly, options = ''): + from numpy.core.multiarray import array + from matplotlib.pyplot import plot + from shapely.geometry import Polygon + + tmp = array(poly.exterior) + plot(tmp[:,0], tmp[:,1], options) + if __name__ == "__main__": import doctest import unittest