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

Re: [pygame] Rotation question



Ok, here's a quick stab at it...

Assuming counterclock rotation about (x,  y).  You want to know where
(x1, y1) will end up.

1. Translate your graph so that (x, y) is the new origin (0, 0).
x2 = x1 - x
y2 = y1 - y

2. Rotate about that origin
x3 = x2 * cos(a)  -  y2 * sin(a)
y3 = x2 * sin(a)  + y2 * cos(a)

3. Translate back to the original reference frame
x4 = x3 + x
y4 = y3 + y

So (x1, y1) --> (x4, y4).

Hope this helps,
André

On 6/19/06, Kamilche <klachemin@xxxxxxxxxxx> wrote:
Given a single pixel location on a bitmap graphic, how can you tell
where that pixel will end up on the new graphic after it's been rotated
by an arbitrary number of degrees?

I'm using the rotation routines supplied with Pygame, but find a need to
rotate the origin of the picture along with it in an easy manner.

--Kamilche