# HG changeset patch # User Nicolas Saunier # Date 1274218509 14400 # Node ID 0d321c23d337df84de739d898e3f7cd4439b280a # Parent 911b52744cebeee1d8ceab7c8f2be21855a119eb added norm functions for Point and accessor methods for MovingObject diff -r 911b52744ceb -r 0d321c23d337 python/moving.py --- a/python/moving.py Mon Apr 12 15:54:20 2010 -0400 +++ b/python/moving.py Tue May 18 17:35:09 2010 -0400 @@ -141,6 +141,24 @@ ''' return Point(self.x-other.x, self.y-other.y) + def norm2Squared(self): + '''2-norm distance (Euclidean distance) + >>> Point(3,2).norm2Squared() + 13 + ''' + return self.x*self.x+self.y*self.y + + def norm2(self): + '2-norm distance (Euclidean distance)' + return sqrt(self.norm2Squared()) + + def distanceNorm2(p1, p2): + ''' + >>> Point.distanceNorm2(Point(3,4),Point(1,7)) + 3.6055512754639891 + ''' + return (p1-p2).norm2() + def aslist(self): return [self.x, self.y] @@ -227,6 +245,18 @@ def length(self): return self.timeInterval.length() + def getPositions(self): + return self.positions + + def getVelocities(self): + return self.velocities + + def getPositionAt(self, i): + return self.positions[i] + + def getVelocityAt(self, i): + return self.velocities[i] + def getXCoordinates(self): return self.positions.getXCoordinates()