def crash(self, ball):
        'Try to crash two balls together.'
        p = ball.pos - self.pos
        a = abs(p)
        if a <= self.rad + ball.rad:
            v = self.vel - ball.vel
            s = _sub(_ang(p), _ang(v))
            if s < _PI_D_2:
                e =  p * (_math.cos(s) * abs(v) / a)
                ball.err += e
                self.err -= e
Try to crash two balls together.
recipes/Python/510397_Physics/recipe-510397.py