implement tile wrapping

fixes #14
This commit is contained in:
Konstantin Käfer
2014-03-05 09:40:32 +01:00
parent b0ddabd6ac
commit 027c6f33b3
9 changed files with 106 additions and 69 deletions

View File

@@ -4,6 +4,10 @@
using namespace llmr;
Tile::Tile(const ID& id)
: id(id) {
}
Tile::ID Tile::parent(const ID& id, int32_t z) {
assert(z < id.z);
ID pos(id);
@@ -29,3 +33,11 @@ std::forward_list<Tile::ID> Tile::children(const ID& id, int32_t z) {
return children;
}
Tile::ID Tile::normalize(const ID& id) {
ID pos(id);
int32_t dim = pow(2, id.z);
while (pos.x < 0) pos.x += dim;
while (pos.x >= dim) pos.x -= dim;
return pos;
}