diff options
Diffstat (limited to 'src/population.h')
-rw-r--r-- | src/population.h | 41 |
1 files changed, 41 insertions, 0 deletions
diff --git a/src/population.h b/src/population.h new file mode 100644 index 0000000..14c9b77 --- /dev/null +++ b/src/population.h @@ -0,0 +1,41 @@ +#pragma once + +namespace population { + +constexpr unsigned d = 3; +constexpr unsigned q = 19; + +constexpr int velocity[q][d] = { + { 0, 1, 1}, {-1, 0, 1}, { 0, 0, 1}, { 1, 0, 1}, { 0,-1, 1}, + {-1, 1, 0}, { 0, 1, 0}, { 1, 1, 0}, {-1, 0, 0}, { 0, 0, 0}, { 1, 0, 0}, {-1,-1, 0}, { 0,-1, 0}, { 1,-1, 0}, + { 0, 1,-1}, {-1, 0,-1}, { 0, 0,-1}, { 1, 0,-1}, { 0,-1,-1} +}; + +unsigned opposite(unsigned iPop) { + return q - 1 - iPop; +} + +std::ptrdiff_t offset(const Cuboid& c, int iX, int iY, int iZ) { + return iX*c[1]*c[2] + iY*c[2] + iZ; +} + +std::ptrdiff_t offset(const Cuboid& c, unsigned iPop) { + return offset(c, velocity[iPop][0], velocity[iPop][1], velocity[iPop][2]); +} + +std::ptrdiff_t max_offset(const Cuboid& c) { + std::ptrdiff_t padding = 0; + for (unsigned iPop=0; iPop < q; ++iPop) { + padding = std::max(padding, std::abs(offset(c, iPop))); + } + return padding; +} + +} + +namespace stage { + +struct pre_collision { }; +struct post_collision { }; + +} |