Why does rotating a sprite drawn in a rectangle offset the sprite by the centre of rotation?

Relevant code here

I want to draw a sprite using a destination rectangle but have the sprite be rotated around the center of the rectangle.

As you can see the function subtracts the origin of rotation from the location of the rectangle. Why? I thought the whole point of specifying a destination rectangle was so that the sprite is actually drawn in the rectangle but this will draw the sprite half outside of the rectangle no matter the rotation.

foo
Left to right: Origin of rotation (0,0) and rotation 0; Origin of rotation (rectangle.Width/2, rectangle.Height/2) and rotation 0; Origin of rotation (rectangle.Width/2, rectangle.Height/2) and rotation pi;

The origin is the origin of your source sprite that it will rotate around

So if your sprite is 32x32, and you wish to rotate around the center you want to use a vector2 of 16,16 for the origin parameter in spritebatch.draw. you then would need to offset your world location

For whats its worth, you are better off using the spritebatch.draw overload that uses a vector2 as the sprite location to draw too. This allows for subpixel drawing as you are using floats for location, instead of the ints from the rectangle. It also will give you super smooth movement and will work if you have a zoom on your camera. It also fixes the issue that your having

Your world location will then be the exact center of your sprite by using an origin of half the sprite width and height.

You can also scale your sprite with a paremeter too

If you need a rectangle for a bounding box collision you will need to re-compute when you move, or for more accuracy make your own bounding box using floats