Changeset 45
- Timestamp:
- 04/05/08 00:06:45 (8 months ago)
- Files:
-
- 1 modified
Legend:
- Unmodified
- Added
- Removed
-
muckaround/cython-getting-started-tutorial/circles.py
r44 r45 81 81 continue 82 82 83 # 83 # Bounce! 84 rel_pos_x = a.x - b.x 85 rel_pos_y = a.y - b.y 86 pos_angle = math.atan2(rel_pos_y, rel_pos_x) 87 mag = (math.hypot(a.dx, a.dy) + math.hypot(b.dx, b.dy)) / 2 88 a.dx = math.cos(pos_angle) * mag 89 a.dy = math.sin(pos_angle) * mag 90 b.dx = -math.cos(pos_angle) * mag 91 b.dy = -math.sin(pos_angle) * mag 84 92 85 93 def render(self):