Matrix OpenGL ES 2.0-围绕轴点2D旋转点(顶点着色器)
我试着围绕2D中的某个点旋转顶点。Matrix OpenGL ES 2.0-围绕轴点2D旋转点(顶点着色器),matrix,opengl-es,opengl-es-2.0,vertex-shader,Matrix,Opengl Es,Opengl Es 2.0,Vertex Shader,我试着围绕2D中的某个点旋转顶点。 我在这里找到了@rabbi76解,但我需要绕z向量旋转。我找到了一个解 vec2 rotate(vec2 point, float degree, vec2 pivot) { float radAngle = -radians(degree);// "-" - clockwise float x = point.x; float y = point.y; float rX = pivot.x + (x - pivot.x) *
我在这里找到了@rabbi76解,但我需要绕z向量旋转。我找到了一个解
vec2 rotate(vec2 point, float degree, vec2 pivot)
{
float radAngle = -radians(degree);// "-" - clockwise
float x = point.x;
float y = point.y;
float rX = pivot.x + (x - pivot.x) * cos(radAngle) - (y - pivot.y) * sin(radAngle);
float rY = pivot.y + (x - pivot.x) * sin(radAngle) + (y - pivot.y) * cos(radAngle);
return vec2(rX, rY);
}
了解