pseudocode - Code a twisted torus -


my question part academic, doesn't belong here, since want code aspect of twisted torus, hope no 1 minds me posing question here. i'm modelling called "grid cells" repeating patterns of activity. need here wrap subset of 2d plane onto torus such walking in of 6 directions return 1 starting point.

torus approach: take square piece of paper , tape top , bottom tube. tape left , right ends of tube donut. if start out in center of piece of paper (that donut), if travel in of 8 directions:

  1. n
  2. ne
  3. e
  4. se
  5. s
  6. sw
  7. w
  8. nw

you circle around donut once , return starting position.

now if choose specific size 'square paper' lets 10x10, environment of size 100x100, when travelling in straight line in environment, 1 loop around 'torus' 10 times, , return same point. benefit here environment can expanded indefinitely, , torus react circling more times

the code trivial involves calculating environment coordinates, mod width/length of 'square paper'. problem that, pythagoras rule, diagonal travels (ne,se,sw,nw) longer other 4 directions (n,e,s,w). deal use equilateral triangles, or hexagonal mesh such if 1 travels in each of 6 directions, travel same distance:

twisted torus: take piece of paper , somehow tape such distance travelled same of following 6 directions:

  1. 0
  2. 60
  3. 120
  4. 180
  5. 240
  6. 300

the problem can't find straight forward explanation of how make twisted torus. have looked on following , vague me

twisted torus video

instructions on making tt

grid cells based on tt i

grid cells based on tt ii

can provide me small snippet of code how implement this? cheers

edit need map continuous space onto twisted torus such travelling in of 6 directions in environment periodically return same location in 'square paper'.


Comments