algorithm - Fetch tiles in a pattern -



algorithm - Fetch tiles in a pattern -

i have big tile grid want select bunch of tiles in specific area. selection of tiles going start black tile.

i made image illustrate tiles want. thing have center tile. can see on image distance center , border tiles manhattan distance.

this explaination of algorithm need. center tile , distance.

std::vector<tile*> gettilesinarea(tile *centertile, int distance) { // calculation , homecoming vector wanted tiles }

note. distance in tiles. can see on image, distance 10 (10 tiles in each direction center tile).

thank people.

assuming each tile has pointers it's neighbors, up, down, right, left, here's basic thought in pseudo code.

gettilesinarea(centertile, distance): returnvector <- {} l = centertile r = centertile (i = 0; < distance; i++) l = l.left r = r.right traverseupdown(returnvector, l, distance-i) traverseupdown(returnvector, r, distance-i) homecoming returnvector traverseupdown(vector, tile, count): vector.add(tile) u = tile d = tile (i=0; i<count; i++) u = u.up d = d.down vector.add(u) vector.add(d)

algorithm geometry

Comments

Popular posts from this blog

php - Android app custom user registration and login with cookie using facebook sdk -

django - Access session in user model .save() -

php - .htaccess Multiple Rewrite Rules / Prioritizing -