# Danger, isometric maths!

This topic is 5038 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

Hello, I was wondering if anyone could help me with a bit of maths I'm struggling with. Given isometric tiles with width 32 and height 16 (Although only 15 of those 16 lines are drawn) and a buffer with a width a multiple of 32 and a height a multiple of 16, how can I determine the number of consecutive isometric lines consisting of the same number of tiles?

##### Share on other sites
perhaps (640/32) - (480/16) + 1 ? just guessing :D

##### Share on other sites
Nah, that's not it. ;)

It seems to be something to do with width / height.
If the result is < 2 there are at least 2 consecutive equal lines along the y axis (As the pic above shows).
If the result is = 2 there are no consecutive equal lines.
If the result is > 2 there are at least 2 consecutive equal lines along the x axis (e.g. 640x240)

All I need to do now is work out exactly how many consecutive lines there are in either extreme. Hmm...

##### Share on other sites
ok, just guessing here..
first we figure out the angle of the tile:
tile_width = 32tile_height = 16tan a = h        -        wtan a = tile_width        -----------        tile_heighta = 26.57...

now, assuming the width of the screen is greater than the height of the screen (it usually is), we calculate the height of the number of tiles that fill up a width of the screen..
height = tan a * screen_width
height = 320 (assuming 640x480)

so to figure out the number of rows, we want to find out how many tiles will fit in the height of the screen minus the amount of space taken up by a diagonal the width of the screen (what we calculated above).
remaining height = screen_height - height
remaining height = 320 (still assuming 640x480)

therefore: count = ((screen_height - remaining_height) / tile_height) + 1

you may have noticed that we take the atan of the width over height and then tan it again later so infact we can skip that stage altogether.. the final formala is therefore:
count = ((screen_height - (tile_height/tile_width * screen_width)) / tile_height) + 1

hope that makes sense...

edit: spelling/grammar

[Edited by - necromancer_df on December 31, 2004 6:42:48 PM]

##### Share on other sites
necromancer_df, you're an absolute star. [wink]
I was gradually working towards that, had done loads of tests and written down data but was going up the wrong path (Using the modulus operator of all things! [embarrass]). The trig was staring me in the face but I was adamant that it wasn't necessary for this. Silly me...

##### Share on other sites
u do realise that cancels down to (sw/tw) - (sh/th) + 1. :D

though i did write the (sw/tw) and (sh/th) to wrong way round....oops

1. 1
2. 2
3. 3
Rutin
22
4. 4
5. 5

• 13
• 19
• 14
• 9
• 9
• ### Forum Statistics

• Total Topics
632936
• Total Posts
3009310
• ### Who's Online (See full list)

There are no registered users currently online

×