# How to find boundaries in an isometric tilemap?

I have an issue with my 2D isometric engine. I'm using my own 2D camera class which works with matrices and need to find the tilemaps boundaries so the user always sees the map.

Currently my map size is 100x100 (with 128x128 tiles) so the calculation (e.g. for the right boundary) is:

var maxX = (TileMap.MapWidth + 1) * (TileMap.TileWidth / 2) - ViewSize.X;
var maxX = (100 + 1) * (128 / 2) - 1360; // = 5104 pixels.


This works fine while having scale factor of 1.0f but not for any other zoom factor. When I zoom out to 0.9f the right border should be at 4953.

I'm using the following code for transformation but I always get a wrong value:

var tempTransform = Matrix.CreateScale(Scale, Scale, 1);
var maxXVector = new Vector2(maxX, 0);
var maxXTransformed = Vector2.Transform(maxXVector, tempTransform).X;


The result is 4593. Logically this value does not seem to be that wrong since a decrease by 10 percent of the map width (5104) should be something around 510

What am I doing wrong?

Here are some pictures so you can see what I mean:

Zoom 1.0f

Zoom 0.9f Thanks for your help!

• If you're only zooming the map and not the view, your code at the moment scales the whole thing, including ViewSize. Is this the problem? And how did you come up with the 4954 value? Also using Matrix and Vector2 just to scale a single number is quite ineffective, since in this case the whole thing boils down to maxXTransformed = maxX * Scale Commented Jun 3, 2014 at 7:53
• Well, not zooming the view size as well seems to be correct. But I still don't get the right value. Using your line leeds to 4457,6 (view size already substracted).I´ll update my initial post with some pictures so you can see what I mean :) Commented Jun 3, 2014 at 8:08