Reposting, cos I've tried loads of stuff and really can't figure this out. It's driving me nuts.
I want to manually rotate each vertex of a 2d rectangle around the center of the shape, without using glRotatef.
I can rotate a point around another point fine, but whatever I try I can't seem to rotate the four corners of the shape around a center point.
My vertices are declared as follows:
vertices[0][0] = x - (width / 2);
vertices[0][1] = y + (height / 2);
vertices[1][0] = x + (width / 2);
vertices[1][1] = y + (height / 2);
vertices[2][0] = x + (width / 2);
vertices[2][1] = y - (height / 2);
vertices[3][0] = x - (width / 2);
vertices[3][1] = y - (height / 2);
I used this code to rotate a point around another point:
void orbit()
{
const float DEG2RAD = (float) 3.14159/180;
angle = angle + (1.0f);
float degInRad = angle*DEG2RAD;
for(int i = 0; i < 4; i++)
{
x = ((cos(degInRad)) - (sin(degInRad)))*40;
y = ((cos(degInRad)) + (sin(degInRad)))*40;
}
}