code: function assignPointsToClusters(clusters, points, assignments) {
      var assignedDifferently = 0;
      var pointIndex = 0;
      for (var i = 0; i < points.length; i++) {
        var p = points[i];
        var clusterIndex = getNearestCluster(clusters, p);
        if (clusterIndex != assignments[pointIndex]) {
          assignedDifferently++;
        }
  
        var cluster = clusters[clusterIndex];
        cluster.addPoint(p);
        assignments[pointIndex++] = clusterIndex;
      }
  
      return assignedDifferently;
    }
docs: Adds the given points to the closest {@link Cluster}.
  
  @param clusters the {@link Cluster}s to add the points to
  @param points the points to add to the given {@link Cluster}s
  @param assignments points assignments to clusters
  @return the number of points assigned to different clusters as the iteration before