MCPcopy Create free account
hub / github.com/ActiveState/code / crash

Method crash

recipes/Python/502252_Physics/recipe-502252.py:97–107  ·  view source on GitHub ↗

Try to crash two balls together.

(self, ball)

Source from the content-addressed store, hash-verified

95 self.rad = radius
96
97 def crash(self, ball):
98 'Try to crash two balls together.'
99 p = ball.pos - self.pos
100 a = abs(p)
101 if a <= self.rad + ball.rad:
102 v = self.vel - ball.vel
103 s = _sub(_ang(p), _ang(v))
104 if s < _PI_D_2:
105 e = p * (_math.cos(s) * abs(v) / a)
106 ball.err += e
107 self.err -= e
108
109 def move(self, frames_per_second):
110 'Update the ball\'s position.&#x27;

Callers 3

updateFunction · 0.45
updateFunction · 0.45
updateFunction · 0.45

Calls 3

cosMethod · 0.80
_subFunction · 0.70
_angFunction · 0.70

Tested by

no test coverage detected