Mercurial > hg > nsaunier > traffic-intelligence
comparison python/moving.py @ 105:9844c69d8fa2
added multiply method to Point
| author | Nicolas Saunier <nico@confins.net> |
|---|---|
| date | Thu, 14 Jul 2011 19:48:30 -0400 |
| parents | 13187af8622d |
| children | 916678481896 |
comparison
equal
deleted
inserted
replaced
| 104:13187af8622d | 105:9844c69d8fa2 |
|---|---|
| 128 def __repr__(self): | 128 def __repr__(self): |
| 129 return self.__str__() | 129 return self.__str__() |
| 130 | 130 |
| 131 def __sub__(self, other): | 131 def __sub__(self, other): |
| 132 return Point(self.x-other.x, self.y-other.y) | 132 return Point(self.x-other.x, self.y-other.y) |
| 133 | |
| 134 def multiply(self, alpha): | |
| 135 return Point(self.x*alpha, self.y*alpha) | |
| 133 | 136 |
| 134 def draw(self, options = ''): | 137 def draw(self, options = ''): |
| 135 from matplotlib.pylab import plot | 138 from matplotlib.pylab import plot |
| 136 plot([self.x], [self.y], 'x'+options) | 139 plot([self.x], [self.y], 'x'+options) |
| 137 | 140 |
