Add off-axis movement
This commit is contained in:
parent
3c6e6947fb
commit
4649658a9b
@ -109,42 +109,44 @@ void DLASystem::addParticleOnAddCircle() {
|
|||||||
cerr << "FAIL " << pos[0] << " " << pos[1] << endl;
|
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
|
// send back the position of a neighbour of a given grid cell
|
||||||
// NOTE: there is no check that the neighbour is inside the grid,
|
// NOTE: there is no check that the neighbour is inside the grid,
|
||||||
// this has to be done separately...
|
// this has to be done separately...
|
||||||
void DLASystem::setPosNeighbour(double setpos[], double pos[], int val) {
|
void DLASystem::setPosNeighbour(double setpos[], double pos[], int val) {
|
||||||
switch (val) {
|
const static double offsets[NEIGHBOURS][3] = {
|
||||||
case 0:
|
{-1, -1, -1},
|
||||||
setpos[0] = pos[0] + 1.0;
|
{-1, -1, 0},
|
||||||
setpos[1] = pos[1];
|
{-1, -1, 1},
|
||||||
setpos[2] = pos[2];
|
{-1, 0, -1},
|
||||||
break;
|
{-1, 0, 0},
|
||||||
case 1:
|
{-1, 0, 1},
|
||||||
setpos[0] = pos[0] - 1.0;
|
{-1, 1, -1},
|
||||||
setpos[1] = pos[1];
|
{-1, 1, 0},
|
||||||
setpos[2] = pos[2];
|
{-1, 1, 1},
|
||||||
break;
|
{0, -1, -1},
|
||||||
case 2:
|
{0, -1, 0},
|
||||||
setpos[0] = pos[0];
|
{0, -1, 1},
|
||||||
setpos[1] = pos[1] + 1.0;
|
{0, 0, -1},
|
||||||
setpos[2] = pos[2];
|
{0, 0, 1},
|
||||||
break;
|
{0, 1, -1},
|
||||||
case 3:
|
{0, 1, 0},
|
||||||
setpos[0] = pos[0];
|
{0, 1, 1},
|
||||||
setpos[1] = pos[1] - 1.0;
|
{1, -1, -1},
|
||||||
setpos[2] = pos[2];
|
{1, -1, 0},
|
||||||
break;
|
{1, -1, 1},
|
||||||
case 4:
|
{1, 0, -1},
|
||||||
setpos[0] = pos[0];
|
{1, 0, 0},
|
||||||
setpos[1] = pos[1];
|
{1, 0, 1},
|
||||||
setpos[2] = pos[2] + 1.0;
|
{1, 1, -1},
|
||||||
break;
|
{1, 1, 0},
|
||||||
case 5:
|
{1, 1, 1}
|
||||||
setpos[0] = pos[0];
|
};
|
||||||
setpos[1] = pos[1];
|
|
||||||
setpos[2] = pos[2] - 1.0;
|
setpos[0] = pos[0] + offsets[val][0];
|
||||||
break;
|
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
|
// 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
|
// make a random move of the last particle in the particleList
|
||||||
void DLASystem::moveLastParticle() {
|
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];
|
double newpos[3];
|
||||||
|
|
||||||
Particle *lastP = particleList[numParticles - 1];
|
Particle *lastP = particleList[numParticles - 1];
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user