I have a small rectangle, with a point at the center. I a开发者_StackOverflowlso have another point, just outside of the rectangle, 10 pixels to the left of the rectangle's center point when the rectangle is sitting vertically, not rotated. How would i go about keeping this outside point in the same place relative to the rectangle when the rectangle is rotated about its center?
thanks
Here is an example of how to rotate one point around another point in XNA:
public Vector2 RotatePoint(Vector2 pointToRotate, Vector2 centerOfRotation, float angleOfRotation)
{
Matrix rotationMatrix = Matrix.CreateRotationZ(angleOfRotation);
return Vector2.Transform(pointToRotate - centerOfRotation, rotationMatrix);
}
Start the "point" at the center point of your rectangle, then translate it out to where you want it, and then rotate it from there.
精彩评论