XNA SpriteBatch works in the Client Space . Where "up" is Y-, not Y + (as in Cartesian space, projection space, and what most people usually choose for their world space). This leads to the appearance of clockwise rotation (not counterclockwise, as it would be in Cartesian space). The actual coordinates that the rotation produces are the same.
Rotations are relative, so they do not โstartโ from any given position.
If you use mathematical functions like sin or cos or atan2 , then the absolute angles always start from the X + axis as zero radians, and the positive direction of rotation rotates in the Y + direction.
The order of SpriteBatch operations looks something like this:
- Sprite starts as a square with the upper left corner at (0,0), its size is the same as the size of its texture (or
SourceRectangle ). - Move the sprite back to its beginning (thus, its beginning begins with (0,0)).
- Scale sprite
- Sprite rotation
- Translate sprite by its position
- Apply matrix from
SpriteBatch.Begin
This puts the sprite in the client space.
Finally, a matrix is โโapplied to each batch to transform this client space into the projection space used by the GPU. (The projection space is from (-1, -1) in the lower left corner of the viewport to (1,1) in the upper right corner.)
Andrew Russell
source share