请问一下这个图像里顶点进行旋转的原理是怎么样的呢?
RT,这个是工程代码的一部分,输入参数x,y,w,h,centerX,centerX应该分别是坐标点的x,y,宽高和中点坐标,
void Rotate(x,y,w,h,centerX,centerX ....){ short vertices[] = { x , y, x + w, y, x + w, y + h, x, y, x + w, y + h, x, y + h }; if(rotation != 0) { TransformVertices(vertices, -centerX, -centerY); RotateVertices(vertices, rotation); TransformVertices(vertices, centerX, centerY); }}void TransformVertices(short* vertices, int x, int y){ for(int i = 0; i < 12; i+=2) { vertices[i] += x; vertices[i+1] += y; }}void RotateVertices(short* vertices, float rotation){ //x1 = x*cosA - y*sinA //y1 = x*sinA + y*cosA double _A = DEGREES_TO_RADIANS(rotation); double sinA = sin(_A); double cosA = cos(_A); for(int i = 0; i < 12; i+=2) { GLshort x = vertices[i]; GLshort y = vertices[i + 1]; vertices[i] = x * cosA - y * sinA; vertices[i+1] = x * sinA + y * cosA; }}