【问题标题】:Rotation matrix with center带中心的旋转矩阵
【发布时间】:2026-01-24 18:35:01
【问题描述】:

在此示例或任何示例中如何计算中心向量。 WolframAlpha:http://www.wolframalpha.com/input/?i=rotate+90+degrees+center+%283%2C0%29

【问题讨论】:

  • 我没睡好。添加到旋转矩阵的向量是 (3, -3) 我如何得到这个值,我没有通过它。

标签: math vector matrix


【解决方案1】:

齐次坐标:

            [ cos(theta) -sin(theta) 0 ]
Rotate    = [ sin(theta)  cos(theta) 0 ]
            [      0           0     1 ]

            [ 1 0 x ]
Translate = [ 0 1 y ]
            [ 0 0 1 ]

所以要执行你的转换,你乘以Translate(x, y) * Rotate(theta) * Translate(-x, -y) 并得到一个转换矩阵。

【讨论】:

  • 你是不是不小心用了同一个变量名来旋转和x坐标?
  • 不应该是 T(x,y)*R*T(-x,-y) 吗?
  • math.stackexchange.com/questions/2093314/… 是我对此提出的问题,答案表明,它必须反过来,因为它是从右到左的乘法。
【解决方案2】:

或者在一个函数语句中

Vector RotateAbout(Vector node, Vector center, double angle)
{
    return new Vector(
        center.X + (node.X-center.X)*COS(angle) - (node.Y-center.Y)*SIN(angle),
        center.Y + (node.X-center.X)*SIN(angle) + (node.Y-center.Y)*COS(angle)
    };
}

【讨论】: