【发布时间】:2020-05-25 08:36:40
【问题描述】:
我正在尝试围绕 2D 中的某个点旋转顶点。 我在这里找到了@Rabbid76 解决方案https://stackoverflow.com/a/48156351/776388,但我需要围绕z-vector 旋转。
【问题讨论】:
标签: matrix opengl-es opengl-es-2.0 vertex-shader
我正在尝试围绕 2D 中的某个点旋转顶点。 我在这里找到了@Rabbid76 解决方案https://stackoverflow.com/a/48156351/776388,但我需要围绕z-vector 旋转。
【问题讨论】:
标签: matrix opengl-es opengl-es-2.0 vertex-shader
我找到了解决办法
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);
}
【讨论】: