rogueviz::flocking:: added some comments

This commit is contained in:
Zeno Rogue 2018-11-18 17:34:26 +01:00
parent 73de211bf2
commit be3a464527
1 changed files with 8 additions and 7 deletions

View File

@ -1,6 +1,11 @@
// flocking simulations
// Copyright (C) 2018 Zeno and Tehora Rogue, see 'hyper.cpp' for details
// based on Flocking by Daniel Shiffman (which in turn implements Boids by Craig Reynold)
// https://processing.org/examples/flocking.html
// Our implementation simplifies some equations a bit.
// example parameters:
// flocking on a torus:
@ -9,7 +14,7 @@
// flocking on the Zebra quotient:
// -geo 4 -flocking 10 -rvshape 3 -zoom .9
// press 'o' when flocking active to change the parameters
// press 'o' when flocking active to change the parameters.
namespace hr {
hyperpoint nearcorner(cell *c, int i);
@ -159,16 +164,12 @@ namespace flocking {
}
}
// a bit simpler rules than original
if(sep_count) velvec += sep * (d * sep_factor / sep_count);
if(align_count) velvec += align * (d * align_factor / align_count);
if(coh_count) velvec += coh * (d * coh_factor / coh_count);
if(i == 0) {
printf("%s\n", display(velvec));
// lines.emplace_back(gmatrix[m->base] * m->at * C0, gmatrix[m->base] * m->at * (C0 + velvec));
// lines.emplace_back(gmatrix[m->base] * m->at * C0, gmatrix[m->base] * m->at * (C0 + sep / hypot2(sep)));
}
vels[i] = hypot2(velvec);
ld alpha = -atan2(velvec);