我有一个小矩形,中心点为一个点。我还有另外一个点,在矩形外面,当矩形垂直放置时,距离矩形中心点向左10像素。当这个矩形绕其中心旋转时,如何使得这个外部点相对于矩形保持在同一位置?
谢谢。
谢谢。
以下是在XNA中如何围绕另一个点旋转一个点的示例:
public Vector2 RotatePoint(Vector2 pointToRotate, Vector2 centerOfRotation, float angleOfRotation)
{
Matrix rotationMatrix = Matrix.CreateRotationZ(angleOfRotation);
return Vector2.Transform(pointToRotate - centerOfRotation, rotationMatrix);
}
从矩形的中心点开始“定位点”,然后将其移动到所需位置,最后从那里旋转。