comparison python/event.py @ 67:ded58c424783

added indicator computation and modified severity indicator constructor
author Nicolas Saunier <nicolas.saunier@polymtl.ca>
date Sun, 07 Nov 2010 04:21:26 -0500
parents f955e83da499
children 19603b5fa578
comparison
equal deleted inserted replaced
66:56fe4ef1377e 67:ded58c424783
33 if i.name == indicatorName: 33 if i.name == indicatorName:
34 return i 34 return i
35 else: 35 else:
36 return None 36 return None
37 37
38 def computeIndicators(self):
39 collisionCourseDotProduct = [0]*self.timeInterval.length()
40 collisionCourseCosine = {}
41 distances = [0]*self.timeInterval.length()
42 for i,instant in enumerate(self.timeInterval):
43 deltap = self.movingObject1.getPositionAtInstant(instant)-self.movingObject2.getPositionAtInstant(instant)
44 deltav = self.movingObject2.getVelocityAtInstant(instant)-self.movingObject1.getVelocityAtInstant(instant)
45 collisionCourseDotProduct[i] = moving.Point.dot(deltap, deltav)
46 distances[i] = deltap.norm2()
47 if collisionCourseDotProduct[i] > 0:
48 collisionCourseCosine[instant] = collisionCourseDotProduct[i]/(distances[i]*deltav.norm2())
49 self.indicators = [moving.SeverityIndicator('Collision Course Dot Product', collisionCourseDotProduct, self.timeInterval),
50 moving.SeverityIndicator('Distances', distances, self.timeInterval),
51 moving.SeverityIndicator('Collision Course Cosine', collisionCourseCosine)]
52
38 class Crossing(moving.STObject): 53 class Crossing(moving.STObject):
39 '''Class for the event of a street crossing 54 '''Class for the event of a street crossing
40 55
41 TODO: detecter passage sur la chaussee 56 TODO: detecter passage sur la chaussee
42 identifier origines et destination (ou uniquement chaussee dans FOV) 57 identifier origines et destination (ou uniquement chaussee dans FOV)