diff trafficintelligence/events.py @ 1150:14140b55e580

corrected issue with motion pattern for motion prediction for safety analysis (to few matches)
author Nicolas Saunier <nicolas.saunier@polymtl.ca>
date Thu, 28 May 2020 01:03:45 -0400
parents 392db62ea1da
children 658f87232536
line wrap: on
line diff
--- a/trafficintelligence/events.py	Wed May 13 00:29:34 2020 -0400
+++ b/trafficintelligence/events.py	Thu May 28 01:03:45 2020 -0400
@@ -193,7 +193,10 @@
             v1 = self.roadUser1.getVelocityAtInstant(instant)
             v2 = self.roadUser2.getVelocityAtInstant(instant)
             deltav = v2-v1
-            velocityAngles[instant] = np.arccos(moving.Point.dot(v1, v2)/(v1.norm2()*v2.norm2()))
+            v1Norm = v1.norm2()
+            v2Norm = v2.norm2()
+            if v1Norm != 0. and v2Norm != 0.:
+                velocityAngles[instant] = np.arccos(moving.Point.dot(v1, v2)/(v1Norm*v2Norm))
             collisionCourseDotProducts[instant] = moving.Point.dot(deltap, deltav)
             distances[instant] = deltap.norm2()
             speedDifferentials[instant] = deltav.norm2()