Calculate distances from centers. More visual implementation of the algorithm.