【问题标题】:OpenGL ES 2.0 - rotate point around pivot point 2D (vertex shader)OpenGL ES 2.0 - 围绕枢轴点 2D 旋转点(顶点着色器)
【发布时间】: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


【解决方案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);
}

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2016-05-04
    • 1970-01-01
    • 2015-07-14
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多