Sections
Timeline
Sub-Sections
Download
Unified Diff
Zip Archive
Metanav
Preferences
About Trac
Links
Slowchop Studios
Gerald Kaszuba
Advertisement

Changeset 45

Show
Ignore:
Timestamp:
04/05/08 00:06:45 (8 months ago)
Author:
gak
Message:
 
Files:
1 modified

Legend:

Unmodified
Added
Removed
  • muckaround/cython-getting-started-tutorial/circles.py

    r44 r45  
    8181                    continue 
    8282 
    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 
    8492 
    8593    def render(self):