Looks like Pyglet uses clockwise rotations with zero meaning north. Mathematicians use counter-clockwise rotations, with zero meaning east. This is the kind of angle you'll get from the atan2 function.
On the bright side, you came up with exactly the right conversion. (I'm assuming you made a typo entering the code into your email, and you were calling math.degrees on the result of atan2, not on the normalized mouse-sprite vector). Also, there's no need to normalize a vector before passing it to atan2. Normalizing a vector only affects its length (sets it to 1)--its direction is unchanged. On Tue, Apr 1, 2008 at 4:04 PM, Scott Benjamin <[EMAIL PROTECTED]> wrote: > > I'm new to pyglet, yet loving the experience thus far. > > On my learning experience I tasked myself to draw a sprite in the > middle of the screen and have it rotate to where the mouse was > clicked. > > The sprite was loaded, anchor points were set to the middle of the > window.I converted the x,y coordinates for the sprite into a vector > and the mouse click location into a vector and calculated the angle > between the two. > > # Used Euclid.py for the vectors and normalization > Nv = math.degrees( MouseVector - > SpriteVector ).normalized() > angle = math.atan2(Nv.y,Nv.x) > > The problem that took me a while to solve was dealing with the fact > the angle was always 90 degrees off. The only way I could get the > sprite to move the correct angle was to subtract it from 90, as the > angles were showing up 90 degrees off: > > sprite.rotation(90 - angle) > > Why does that occur? The sprite always loads right side up (facing > north if the window). Is it my math or maybe the angle which the > sprite's. > > I appreciate another set of eyes. > > Cheers, > > Scott > > > --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
