Mercurial Hosting > traffic-intelligence
comparison python/moving.py @ 575:13df64a9ff9d
added function to access point class as 2D list
author | Nicolas Saunier <nicolas.saunier@polymtl.ca> |
---|---|
date | Wed, 13 Aug 2014 10:51:16 -0400 |
parents | e24eeb244698 |
children | 0eff0471f9cb |
comparison
equal
deleted
inserted
replaced
574:e24eeb244698 | 575:13df64a9ff9d |
---|---|
177 def __sub__(self, other): | 177 def __sub__(self, other): |
178 return Point(self.x-other.x, self.y-other.y) | 178 return Point(self.x-other.x, self.y-other.y) |
179 | 179 |
180 def __neg__(self): | 180 def __neg__(self): |
181 return Point(-self.x, -self.y) | 181 return Point(-self.x, -self.y) |
182 | |
183 def __getitem__(self, i): | |
184 if i == 0: | |
185 return self.x | |
186 elif i == 1: | |
187 return self.y | |
188 else: | |
189 raise IndexError() | |
182 | 190 |
183 def orthogonal(self): | 191 def orthogonal(self): |
184 return Point(self.y, -self.x) | 192 return Point(self.y, -self.x) |
185 | 193 |
186 def multiply(self, alpha): | 194 def multiply(self, alpha): |