This is my code for rotating a vertex quad sized actualSize
and centered at x,y
:
vertexData.position(bufPosition * 12);
float x1=(-actualSize / 2 + x);
float y1=(-actualSize / 2 + y);
float x2=(actualSize / 2 + x);
float y2=(-actualSize / 2 + y);
float x3=(-actualSize / 2 + x);
float y3=(actualSize / 2 + y);
float x4=(actualSize / 2 + x);
float y4=(actualSize / 2 + y);
float cos=FastMath.cos(angle);
float sin=FastMath.sin(angle);
vertices[0] = x1*cos-y1*sin;
vertices[1] = x1*sin+y1*cos;
vertices[2] = 0;
vertices[3] = x2*cos-y2*sin;
vertices[4] = x2*sin+y2*cos;
vertices[5] = 0;
vertices[6] = x3*cos-y3*sin;
vertices[7] = x3*sin+y3*cos;
vertices[8] = 0;
vertices[9] = x4*cos-y4*sin;
vertices[10] = x4*sin+y4*cos;
vertices[11] = 0;
vertexData.put(vertices, 0, 12);
However, I’d like to rotate around another pivot point (not centered). Any tips? Thanks!