Mercurial > hg > nsaunier > traffic-intelligence
comparison python/moving.py @ 41:eb78c6edc0c8
added drawing for Point
| author | Nicolas Saunier <nico@confins.net> |
|---|---|
| date | Fri, 28 May 2010 20:25:45 -0400 |
| parents | 9f16aee24b7e |
| children | 6d11d9e7ad4e |
comparison
equal
deleted
inserted
replaced
| 40:9f16aee24b7e | 41:eb78c6edc0c8 |
|---|---|
| 138 ''' | 138 ''' |
| 139 >>> Point(3,4)-Point(1,7) | 139 >>> Point(3,4)-Point(1,7) |
| 140 (2.000000,-3.000000) | 140 (2.000000,-3.000000) |
| 141 ''' | 141 ''' |
| 142 return Point(self.x-other.x, self.y-other.y) | 142 return Point(self.x-other.x, self.y-other.y) |
| 143 | |
| 144 def draw(self, options = ''): | |
| 145 from matplotlib.pylab import plot | |
| 146 plot([self.x], [self.y], 'x'+options) | |
| 143 | 147 |
| 144 def norm2Squared(self): | 148 def norm2Squared(self): |
| 145 '''2-norm distance (Euclidean distance) | 149 '''2-norm distance (Euclidean distance) |
| 146 >>> Point(3,2).norm2Squared() | 150 >>> Point(3,2).norm2Squared() |
| 147 13 | 151 13 |
