   XNA matrices
  I am having some trouble with matrices.  I think its simply the order of operation's that I am using for the matrices.Matrix thisSprite =  Matrix.CreateTranslation(this.Origin.X,-this.Origin.Y,0)*//0,0,0 Matrix.CreateRotationZ(MathHelper.ToRadians(this.Rotation))*//-30 Matrix.CreateScale(this.Scale.X, this.Scale.Y, 1) *//1,1,1 Matrix.CreateTranslation(this.Position.X,this.Position.Y,0);//500,300,0  Matrix invertSprite = Matrix.Invert(thisSprite);Vector2 pos1 = new Vector2(mouseX, mouseY);  Vector2 pos2 = Vector2.Transform(pos1, invertSprite);If I don't rotate the sprite then the matrix work's fine.So what am I doing wrong with this matrix?   
  1. Translate by -Origin [x as well as y]2. Rotate3. Scale4. Translate to +Position [that is if the origin is supposed to move to the position; otherwise translate by +Origin beforeThe error should be in your first translation, where you translate by -Y, but +X, which seems odd. Try -X.I don't get why you're inverting the matrix, but I'm sure you have your reasons. But just for the sake of it, try it without the inverting and see if it works for you.Hope I could help :-)   ;  Well in the first translation It's all 0,0,0 so even if its negative x it wouldn't matter.And I am inverting the matrix so I could take a screen coordinate and multiple it by the inverse matrix to find where it would land on the original image for perfect pixel collision.   ;  It actually does matter if the value goes negative. Just because you don't see it doesn't mean it isn't there. And the fact that it isn't working properly is either the inverted matrix or the wrong origin-translation. Check if the origin really always is 0,0.If you don't do the first translation correctly, the rotation will not be as expected. I assume your "Origin"-value is the point in the object around which it should be rotated afterwards.If you want to rotate an object around the origin 50,50 you would approach it like this:1. Translate by -50,-502. Rotate3. Translate by 50,50This way the object will be rotated around the point 50,50 but will still be at position 0,0. Then scale it and transform it to the position you want it to be.Maybe you should explain in detail which effect you're trying to achieve.   ;  No, I meant that origin.x is equal to 0 so -0=0.What I am trying to achieve is pixel perfect collision detection.Quote:For a point c on the screen: {Find point c that is rendered in image A.If the pixel is non transparent{    COLLISION!} }Basically I just use the inverse of the image to translate point c back into the color array of image A.  Then I check the color array and if its not transparent then there's a collision.Basically its Riemer's tutorial, but reduced down to one point only.http://www.riemers.net/eng/Tutorials/XNA/Csharp/Series2D/Coll_Detection_Overview.php   ;  Riemer has the best tutorials if you're just getting into XNA :D I love his stuff!Anyways, I think you should scale before rotating. If it still doesn't work, tell us what exactly is off. Try to set rotation to 0, then update it every frame to see how it's going, then tell us how the fault makes itself recognizable. That's how I always go about the matrices problems when I encounter them :3Have you tried posting in his forums? Most of the time Riemer himself is a big help, or another member of his forums.   