Sign in to follow this  

Danger, isometric maths!

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

If you intended to correct an error in the post then please contact us.

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 this post


Link to post
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 this post


Link to post
Share on other sites
ok, just guessing here..
first we figure out the angle of the tile:

tile_width = 32
tile_height = 16

tan a = h
-
w
tan a = tile_width
-----------
tile_height
a = 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 this post


Link to post
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 this post


Link to post
Share on other sites

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

If you intended to correct an error in the post then please contact us.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this