Jump to content

View more

View more

Image of the Day

Boxes as reward for our ranking mode. ヾ(☆▽☆)
#indiedev #gamedev #gameart #screenshotsaturday https://t.co/ALF1InmM7K
IOTD | Top Screenshots

The latest, straight to your Inbox.

Subscribe to GameDev.net Direct to receive the latest updates and exclusive content.


Sign up now

toroidal array

4: Adsense

Old topic!

Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.


  • You cannot reply to this topic
3 replies to this topic

#1 Lord_Vader   Members   

125
Like
0Likes
Like

Posted 07 May 2012 - 10:34 AM

Hello everybody,

Can someone write me a few words about what is a toroidal array data type and how it compares with a normal array. The way that I understand it is that it is almost like a circular double linked list with constant size.
If you provide me a link even better.

I did a search over the internet and some books about data structures but I didn't find any relevant and explanatory link.

Thanks

#2 Antheus   Members   

2409
Like
1Likes
Like

Posted 07 May 2012 - 11:00 AM

For a 2D array with dimensions NxM:

torodial[i, j] = regular[i % N, j % M];

It doesn't have a use as such, but some algorithms may benefit from this property. For example:
A B
C D

// toroidal array now contains sequence:
ABABABABAB
and
ACACACACACACACACACAC....

It basically just says that rows and columns wrap around.

#3 Slavik81   Members   

360
Like
0Likes
Like

Posted 07 May 2012 - 11:00 AM

I don't think this would normally be a double-linked list if it's of constant size. You can achieve the same effect by using modulo (%) on the index accessors of a normal 2D array, bounding them within the width or height of the array.

#4 swiftcoder   Senior Moderators   

18214
Like
0Likes
Like

Posted 07 May 2012 - 11:21 AM

It doesn't have a use as such, but some algorithms may benefit from this property.

It is however very useful for representing game maps that wrap around at the edges - for instance, when implementing Conway's Game of Life.

Also worth mentioning that GPU texture lookups wrap by default, which provides a very simple case of toroidal access.

Tristam MacDonald - Software Engineer @ Amazon - [swiftcoding] [GitHub]





Old topic!

Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.