comparison python/moving.py @ 259:8ab76b95ee72

added code to save collision points and crossing zones in txt files
author Nicolas Saunier <nicolas.saunier@polymtl.ca>
date Tue, 24 Jul 2012 15:18:12 -0400
parents d90be3c02267
children 0c0b92f621f6
comparison
equal deleted inserted replaced
258:d90be3c02267 259:8ab76b95ee72
238 @staticmethod 238 @staticmethod
239 def fromPoint(p): 239 def fromPoint(p):
240 from math import atan2 240 from math import atan2
241 norm = p.norm2() 241 norm = p.norm2()
242 if norm > 0: 242 if norm > 0:
243 angle = atan2(p.x, p.y) 243 angle = atan2(p.y, p.x)
244 return NormAngle(norm, angle) 244 return NormAngle(norm, angle)
245 245
246 def __add__(self, other): 246 def __add__(self, other):
247 'a norm cannot become negative' 247 'a norm cannot become negative'
248 return NormAngle(max(self.norm+other.norm, 0), self.angle+other.angle) 248 return NormAngle(max(self.norm+other.norm, 0), self.angle+other.angle)