PDA

View Full Version : How to rotate a 2d shape around it's center.



Phoresis
02-09-2007, 01:55 AM
Just wondering how you make it so a 2d shape can be rotated around the center of the shape.

RigidBody
02-09-2007, 01:57 AM
if the shape is in x-y-plane and the center is at (cx, cy, 0):

glTranslatef(cx, cy, 0);
glRotatef(angle, 0., 0., 1.);
glTranslatef(-cx, -cy, 0);

Phoresis
02-09-2007, 02:02 AM
hrmm this makes my shapes dissapear off the screen, because the shape's vertices are like:

0,0 ----------w, 0
| |
| |
| |
| |
0,-h----------w, -h

RigidBody
02-09-2007, 02:20 AM
i think it is now time to post some code...

Phoresis
02-09-2007, 02:22 AM
it's ok I've sorted it now. thanks for your help!!