Exemplo n.º 1
0
        private void AddToCluster(KMPoint point)
        {
            double  minDistance = 0;
            Cluster current     = null;

            if (point == null)
            {
                throw new NullReferenceException("point is null");
            }

            foreach (var cluster in _clusters)
            {
                double distance = point.GetDistanceTo(cluster.Center);

                if (current == null || minDistance > distance)
                {
                    minDistance = distance;
                    current     = cluster;
                }
            }

            if (current != null)
            {
                current.AddPoint(point);
            }
        }