Add off-axis movement

This commit is contained in:
Joshua Coles 2023-03-14 15:03:27 +00:00
parent 3c6e6947fb
commit 4649658a9b

View File

@ -109,42 +109,44 @@ void DLASystem::addParticleOnAddCircle() {
cerr << "FAIL " << pos[0] << " " << pos[1] << endl;
}
const static size_t NEIGHBOURS = 26;
// send back the position of a neighbour of a given grid cell
// NOTE: there is no check that the neighbour is inside the grid,
// this has to be done separately...
void DLASystem::setPosNeighbour(double setpos[], double pos[], int val) {
switch (val) {
case 0:
setpos[0] = pos[0] + 1.0;
setpos[1] = pos[1];
setpos[2] = pos[2];
break;
case 1:
setpos[0] = pos[0] - 1.0;
setpos[1] = pos[1];
setpos[2] = pos[2];
break;
case 2:
setpos[0] = pos[0];
setpos[1] = pos[1] + 1.0;
setpos[2] = pos[2];
break;
case 3:
setpos[0] = pos[0];
setpos[1] = pos[1] - 1.0;
setpos[2] = pos[2];
break;
case 4:
setpos[0] = pos[0];
setpos[1] = pos[1];
setpos[2] = pos[2] + 1.0;
break;
case 5:
setpos[0] = pos[0];
setpos[1] = pos[1];
setpos[2] = pos[2] - 1.0;
break;
}
const static double offsets[NEIGHBOURS][3] = {
{-1, -1, -1},
{-1, -1, 0},
{-1, -1, 1},
{-1, 0, -1},
{-1, 0, 0},
{-1, 0, 1},
{-1, 1, -1},
{-1, 1, 0},
{-1, 1, 1},
{0, -1, -1},
{0, -1, 0},
{0, -1, 1},
{0, 0, -1},
{0, 0, 1},
{0, 1, -1},
{0, 1, 0},
{0, 1, 1},
{1, -1, -1},
{1, -1, 0},
{1, -1, 1},
{1, 0, -1},
{1, 0, 0},
{1, 0, 1},
{1, 1, -1},
{1, 1, 0},
{1, 1, 1}
};
setpos[0] = pos[0] + offsets[val][0];
setpos[1] = pos[1] + offsets[val][1];
setpos[2] = pos[2] + offsets[val][2];
}
// when we add a particle to the cluster, we should update the cluster radius
@ -170,7 +172,7 @@ void DLASystem::updateClusterRadius(double pos[]) {
// make a random move of the last particle in the particleList
void DLASystem::moveLastParticle() {
int rr = rgen.randomInt(6); // pick a random number in the range 0-3, which direction do we hop?
int rr = rgen.randomInt(NEIGHBOURS); // pick a random number in the range 0-3, which direction do we hop?
double newpos[3];
Particle *lastP = particleList[numParticles - 1];