shift method

bool shift()

Implementation

bool shift() {
  var nextLocation = List<num>.filled(location.length, 0.0);
  int n = 0;
  instances.forEach((Instance instance) {
    for (int i = 0; i < instance.location.length; i++) {
      nextLocation[i] =
          (nextLocation[i] * n + instance.location[i]) / (n + 1);
    }
    n++;
  });
  bool
      shifted = /*List<bool>.generate(location.length,
          (i) => (location[i] - nextLocation[i]).abs() < precision)*/
      [
    for (var i = 0; i < location.length; i++)
      (location[i] - nextLocation[i]).abs() < precision
  ].any((x) => !x);
  location = nextLocation;
  return shifted;
}