kmeans-clustering-unity
kmeans-clustering-unity copied to clipboard
IndexOutOfRangeException: Index was outside the bounds of the array.
Sometimes I'm getting this error when trying to find Clusters on a Vector2[].
The error points to this line clusters[clustering[i]][clustersCurIdx[clustering[i]]] = i;
, in the KMeans
class.
int[] clustersCurIdx = new int[clusterCount];
for (int i = 0; i < clustering.Length; i++) {
clusters[clustering[i]][clustersCurIdx[clustering[i]]] = i;
++clustersCurIdx[clustering[i]];
}
Hi @Shadercloud. Thanks for the issue. I don't actively maintain this repository. Don't hesitate to file a PR if you've fixed it yourself
It looks like a floating point rounding issue at first glance