The existing code recomputes the group center on each iteration
(causing that fun looking bug where things spiral until near-
equilibrium is reached). I also changed a call to arc sine and an
'if' statement to a single atan2 (arc tangent given 2 parameters will
get the quadrant correctly). If you want to restore the bug you can
move the 'sx = ...' line inside the loop (makes the demo more fun to
watch :) ).
Fix for Group.Rotate():
def rotate(self, angle):
"""
Rotate all members around the group's center of mass
positive angle rotates counterclockwise
"""
sx, sy = self.x, self.y
for o in self.members:
dist = math.sqrt((o.x-sx)**2.+(o.y-sy)**2.)
#angle from horizontal
afh = math.atan2(o.y-sy, o.x-sx)
x = sx+math.cos(afh+angle)*dist
y = sy+math.sin(afh+angle)*dist
o.setX(x)
o.setY(y)
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"pyglet-users" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/pyglet-users?hl=en
-~----------~----~----~----~------~----~------~--~---