# Keep Mini map static after rotating / zooming with camera

Hi I am making a 2D game, where the Camera is able to rotate / zoom in or out on the camera focus (the player usually).

However my game also contains a mini-map, and so far whenever I have to rotate / zoom my camera the mini-map rotates and zooms accordingly. This behaviour was expected, but now I am a little stuck on "un-doing" the changes the view transformation has on my mini-map. What I want to happen is to essentially keep my mini-map statically in the same position throughout the game no matter how the camera rotates or zooms.

I am extremely rusty with my linear algebra / 3D transformations but I have tried the following...

My first thought was, I thought all I had to do was to transform the mini-map origin point with the view matrix, then undo the scaling of the zoom against the mini-map width / height. The zooming was fixed, but the mini-map still rotated so this did not work.

My second try, I remembered to undo the change of a matrix, I would have to multiply the transform by its inverse. So I tried to calculate the inverse matrix, however the determinant of the view matrix was 0, so I could not find an inverse.

Ok... well I guess I'll just see if I can get the rotation down, since I got the zoom to work... So I transformed my mini-map origin by the inverse rotation matrix applied by the view matrix... The mini-map is rotating now, but is not staying in the fixed position I was hoping for.

I was wondering, if anyone here can give me a push in the right direction, or a hint towards a more elegant solution overall. If people would like more information I can upload images, show code... But what I wrote above is exactly how my code would look.

Thanks for any help!

• Can you try to succinctly describe what you want to happen? I read this a couple times and all I can figure out is that you want to undo something, but you're not explicit. Commented Dec 21, 2013 at 0:37
• Sorry, I made an edit to the original post. What I want to happen is to essentially keep my mini-map statically in the same position throughout the game no matter how the camera rotates or zooms. However currently whenever I zoom or rotate the camera the map zoom or rotates along with it. I tried to undo the change by trying to transform the original point of the mini-map by the inverse of view transformation but there was no inverse. So then I tried the inverse of the rotation matrix but that didn't work. I tried a few other things but couldn't come up with a solution. Commented Dec 21, 2013 at 0:46
• @BZhang Is there some reason you don't just compute the mini-map's matrix once, and keep using the same matrix for the duration of the game? In other words, why is the mini-map matrix based on the current camera matrix at all, if you don't want it to mirror the camera motion? Commented Dec 21, 2013 at 1:25
• You should figure out what sort of transformation you want to apply, and then apply only that transformation to your minimap. It sounds like you want a very simple model to camera type of transformation. Since the minimap is static you can, like Nathan Reed suggested, calculated this transformation a single time and use it upon the minimap images. To go from model to world you'll generally apply scale, then rotation, then translation. The scale and translation might be the only things you need to do. Commented Dec 21, 2013 at 1:34
• Calculating inversions will be harder, and these are transform inversions, not full matrix inversions. This requires some understanding you might not have right now. To invert a transformation I actually decompose a matrix into the scale rotation and translation components, invert those separately and build the final inverted result. You can try checking it out if you like: bitbucket.org/rgaul/sel/src/… Commented Dec 21, 2013 at 1:35

No, usually you don't undo transform by applying inverse. Because precision errors love to accumulate. Instead, either precalculate desired transform and set it directly, or reset current transform to identity and start over.

This answer is api-agnostic. If there is way to manipulate current transform, then should be also way for resetting it. (I am not familiar with XNA, sorry.)

You would be able to render your minimap to a texture (or alternatively use a pre-existing texture).