summaryrefslogtreecommitdiff
path: root/src/population.h
blob: 14c9b77f6ab55ea320a266ca9726dee3fa53a758 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
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 { };

}