# XNA 2D rotation Matrix offset/origin

I'm currently struggling with finding the offset for my original camera translation after I have applied a rotation for it.

transform = Matrix.CreateScale(new Vector3(1, 0.75f, 1))
* Matrix.CreateTranslation(-playerpos.X+dash, -playerpos.Y, 1);

transform2 = rotation
* Matrix.CreateScale(new Vector3(1, 0.75f, 0))
* Matrix.CreateTranslation(-playerpos.X + dash, -playerpos.Y, 0);


My original transform matrix is for the camera that follows the player, I use transform2 for sprites I want to rotate.

spriteBatch.Begin( SpriteSortMode.Immediate, BlendState.AlphaBlend, null,
null, null, null, camera.transform);

spriteBatch.Begin( SpriteSortMode.Immediate, BlendState.AlphaBlend, null,
null, null, null, camera.transform2);


Edit:

for (int i = 0; i < 3; i++)
{
spriteBatch.Draw( world.mcircle[i],
new Vector2(5320, 1200),
null,
Color.White,
(world.finishtime * 5) / (i + 1),
new Vector2(50, 50),
3f,
SpriteEffects.None,
0);
}


So I pass two different transformations based on whether I want stuff to rotate or not.

But I just can't seem to find the correct offset in position for the rotated sprites, they seem to gravitate towards (0, 0)? as the rotational value increases.

I'd be really glad if someone could help me out with this.

Edit: I think I'd only need a proper origin for the sprite position, because currently it goes towards (0, 0) and I'm unsure how to incorporate one in this state.

Edit:

Tried several origin points for transform2, but when I input the object's coordinates as source, it just displaces it by that amount, and when I set the object's position to (0,0) it still has the same effect as if having the original origin point.

transform2 = Matrix.CreateTranslation(0, 0, 0)
* (rotation * Matrix.CreateScale(new Vector3(1, 0.75f, 0))
* Matrix.CreateTranslation((-playerpos.X + dash), -playerpos.Y, 0)); //just an example currently

• For what purpose are you using the negative value of the player's X and Y position? Also watch your multiplication ordering on your matrices. Multiplying the scale after the rotation can have undesired effects. – Jason H Aug 17 '15 at 7:33
• That gives me the view matrix translation which follows the player, otherwise any coordinates I give are off, and currently for some odd reason the only way my rotated texture shows properly if I do it in this order. I'll update my OP with some new code which I think might help narrow the solution. – Razeal Aug 17 '15 at 12:56
• Please remember to reserve edits for substantial changes only, it's not to be used to "bump" a question. Thanks. – MichaelHouse Aug 19 '15 at 13:25

transform2 =