[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

Re: [pygame] Rotate image around another point?



But maybe it'll work if you first rotate the imagedata around the
centerpoint using pygame.transform.rotate(...) and then rotate the
centerpoint around the wanted rotation point? Havn't tried it yet
though. Sounds reasonably but what do you think?

/John

tor 2007-04-19 klockan 12:24 +0200 skrev altern:
> john is talking about the actual image surface data not just the sprite 
> location. i guess you might need something like PIL library, but i would 
> not really know how to do this.
> 
> John Eriksson(e)k dio:
> > But that is not what I'm trying to do.I want to rotate the actual
> > imagedata (like rotating an image using PohotSshop or GIMP). Not just
> > the location where the image is drawn. 
> > 
> > The pygame.transform.rotate(...) function does that but always rotates
> > the imagedata about it's center.
> > 
> > /John
> > 
> > tor 2007-04-19 klockan 11:02 +0200 skrev Ulf EkstrÃm:
> >> On 4/19/07, John Eriksson <john@xxxxxxxxxxxx> wrote:
> >>> Well, no.
> >>>
> >>> I'm looking for a way to rotate the imagedata (like
> >>> pygame.transform.rotate(...)) but your example rotates the image
> >>> location. Right?
> >> It is actually the same thing. Rotation around some arbitrary point
> >> can be decomposed into a rotation around some other point followed by
> >> a translation. Suppose you have a function R which rotates things
> >> around the origin. To write a function Rp which rotates around the
> >> point p (p and q are vectors), you do
> >>
> >> Rp(q) = R(q-p)+p
> >>
> >> Since R is a linear function you can do
> >>
> >> Rp(q) = R(q) + p - R(p)
> >>
> >> So rotating around p is the same as rotating around the origin and
> >> then translating by p - R(p).
> >>
> >> Ulf
> > 
> >