comparison python/moving.py @ 516:bce1fe45d1b2

corrected bugs detected by tests (because of moving functions around modules
author Nicolas Saunier <nicolas.saunier@polymtl.ca>
date Fri, 06 Jun 2014 14:14:01 -0400
parents 727e3c529519
children 47d9970ee954
comparison
equal deleted inserted replaced
515:727e3c529519 516:bce1fe45d1b2
274 and the circle of radius collisionThreshold around the other road user''' 274 and the circle of radius collisionThreshold around the other road user'''
275 from math import sqrt 275 from math import sqrt
276 dv = v1-v2 276 dv = v1-v2
277 dp = p1-p2 277 dp = p1-p2
278 a = dv.norm2Squared()#(v1.x-v2.x)**2 + (v1.y-v2.y)**2 278 a = dv.norm2Squared()#(v1.x-v2.x)**2 + (v1.y-v2.y)**2
279 b = 2*dot(dv, dp)#2 * ((p1.x-p2.x) * (v1.x-v2.x) + (p1.y-p2.y) * (v1.y-v2.y)) 279 b = 2*Point.dot(dv, dp)#2 * ((p1.x-p2.x) * (v1.x-v2.x) + (p1.y-p2.y) * (v1.y-v2.y))
280 c = dp.norm2Squared() - collisionThreshold**2#(p1.x-p2.x)**2 + (p1.y-p2.y)**2 - collisionThreshold**2 280 c = dp.norm2Squared() - collisionThreshold**2#(p1.x-p2.x)**2 + (p1.y-p2.y)**2 - collisionThreshold**2
281 281
282 delta = b**2 - 4*a*c 282 delta = b**2 - 4*a*c
283 if delta >= 0: 283 if delta >= 0:
284 deltaRoot = sqrt(delta) 284 deltaRoot = sqrt(delta)