我正在尝试围绕2D中的某个点旋转顶点。 我在这里https://stackoverflow.com/a/48156351/776388找到了@ Rabbid76解决方案,但我需要绕着z矢量旋转。
答案 0 :(得分:1)
我找到了解决方法
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);
}