Mercurial Hosting > traffic-intelligence
changeset 555:f13220f765e0
added static methods to create trajectories and moving objects
author | Nicolas Saunier <nicolas.saunier@polymtl.ca> |
---|---|
date | Sun, 13 Jul 2014 23:34:00 -0400 |
parents | 7d051afcb22d |
children | dc58ad777a72 |
files | python/moving.py |
diffstat | 1 files changed, 15 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- a/python/moving.py Fri Jul 11 16:25:57 2014 -0400 +++ b/python/moving.py Sun Jul 13 23:34:00 2014 -0400 @@ -420,6 +420,16 @@ self.positions = [[],[]] @staticmethod + def generate(p, v, nPoints): + t = Trajectory() + p0 = Point(p.x, p.y) + t.addPosition(p0) + for i in xrange(nPoints-1): + p0 += v + t.addPosition(p0) + return t, Trajectory([[v.x]*nPoints, [v.y]*nPoints]) + + @staticmethod def load(line1, line2): return Trajectory([[float(n) for n in line1.split(' ')], [float(n) for n in line2.split(' ')]]) @@ -724,6 +734,11 @@ self.features = [] # compute bounding polygon from trajectory + @staticmethod + def generate(p, v, timeInterval): + positions, velocities = Trajectory.generate(p, v, int(timeInterval.length())) + return MovingObject(timeInterval = timeInterval, positions = positions, velocities = velocities) + def getObjectInTimeInterval(self, inter): '''Returns a new object extracted from self, restricted to time interval inter'''