/// <summary>
/// Translates a point around an origin
/// </summary>
/// <param name="point">Point that is going to be translated</param>
/// <param name="originPoint">Origin of rotation</param>
/// <param name="rotationAxis">Axis to rotate around</param>
/// <param name="radiansToRotate">Radians to rotate</param>
/// <returns>Translated point</returns>
public static Vector3 RotateAroundPoint(Vector3 point, Vector3 originPoint, Vector3 rotationAxis, float radiansToRotate)
{
Vector3 rotatedVect = Vector3.Transform(point, Matrix.CreateFromAxisAngle(rotationAxis, radiansToRotate));
rotatedVect -= originPoint;
return rotatedVect;
}
This should work in 2D by changing the vector3s to vector2s. Although I haven't tried it in 2D yet. Your axis for rotation would likely just be Vector2.UnitY every time. Although, like I said, I've never tried this stuff in 2D.
EDIT: Oh, and the guy above me is right. The stuff on that page is what is occuring above, only much simpler (to most).
XNA QuickStart Engine |
My site"I'll be whatever I want to do!", Philip J. Fry