Rotation problem.

I’m having a problem rotating a 2d shape with the mouse by dragging a corner and pulling it round.

I would like to rotate it manually by multiplying each vertex so that the vertex co-ordinates actually change, but can’t figure out the math to do this.

Currently I’m just using glRotate but it doesnt seem to rotate but just rock back and forth when dragging one way. Here is my code.

			float centerX = items[test-10]->getX();
			float centerY = items[test-10]->getY();
			float distFromCenter = abs((long) sqrt(((x - centerX) * (x - centerX)) + ((y - centerY) * (y - centerY))));
			float moveDist = sqrt((xDiff * xDiff) + (yDiff * yDiff));
			float angle = atan(moveDist / distFromCenter) / 0.0174532925;
			// posative negative amount
            if(((mouseX > x) && (mouseY < centerY)) &#0124;&#0124; ((mouseX < x) && (mouseY > centerY)) &#0124;&#0124; ((mouseY > y) &&
            (mouseX < centerX)) &#0124;&#0124; ((mouseY > y) && (mouseX > centerX)))
            {
				items[test-10]->rotate(angle);
			}
			else
			{
				items[test-10]->rotate(-angle);
			}

i think one of my main problems is that it doesn’t seem to spin fast enough to keep up with the mouse cursor, and the other problem is that the if statement just doesn’t seem to work properly, even though in my mind the logic is right.

I think this might have something to do with my co-ordinate system but i’m not sure. need help :frowning: