//TODO: Use Convex Hull? public double DistanceMetric(ClusterPrototype otherCluster) { var p1 = Point.FindNearestPoint(this.center, otherCluster.Points); var p2 = Point.FindNearestPoint(otherCluster.Center, this.Points); return(Point.Distance(p1, p2)); }
private void SetCenterRandomlyForEmptyCluster(ClusterPrototype cluster) { if (cluster.PointCount == 0) { cluster.SetCenter(this.random.Next(0, this.size.Width - 1), this.random.Next(0, this.size.Height - 1), this.random.Next((int)this.zRange.Min, (int)this.zRange.Max)); } }
public IList <ClusterPrototype> MergeClustersIfRequired(IList <ClusterPrototype> clusters) { var clustersToIterateOver = new List <ClusterPrototype>(clusters); foreach (var cluster in clustersToIterateOver) { foreach (var otherCluster in new List <ClusterPrototype>(clusters)) { if (cluster != otherCluster && this.IsMergeRequired(cluster, otherCluster)) { clusters.Remove(cluster); clusters.Remove(otherCluster); clusters.Add(ClusterPrototype.Merge(cluster, otherCluster)); } } } return(clusters); }
private bool IsMergeRequired(ClusterPrototype cluster1, ClusterPrototype cluster2) { return(cluster1.DistanceMetric(cluster2) < this.settings.MergeMinimumDistanceToCluster || Point.Distance(cluster1.Center, cluster2.Center) < this.settings.MergeMaximumClusterCenterDistances || Point.Distance(cluster1.Center.X, cluster1.Center.Y, cluster2.Center.X, cluster2.Center.Y) < this.settings.MergeMaximumClusterCenterDistances2D); }
//TODO: Use Convex Hull? public double DistanceMetric(ClusterPrototype otherCluster) { var p1 = Point.FindNearestPoint(this.center, otherCluster.Points); var p2 = Point.FindNearestPoint(otherCluster.Center, this.Points); return Point.Distance(p1, p2); }
public static ClusterPrototype Merge(ClusterPrototype cluster1, ClusterPrototype cluster2) { return new ClusterPrototype(Point.Center(cluster1.Center, cluster2.Center), cluster1.points.ToList().Union(cluster2.points).ToList()); }
private bool IsMergeRequired(ClusterPrototype cluster1, ClusterPrototype cluster2) { return cluster1.DistanceMetric(cluster2) < this.settings.MergeMinimumDistanceToCluster || Point.Distance(cluster1.Center, cluster2.Center) < this.settings.MergeMaximumClusterCenterDistances || Point.Distance(cluster1.Center.X, cluster1.Center.Y, cluster2.Center.X, cluster2.Center.Y) < this.settings.MergeMaximumClusterCenterDistances2D; }
public static ClusterPrototype Merge(ClusterPrototype cluster1, ClusterPrototype cluster2) { return(new ClusterPrototype(Point.Center(cluster1.Center, cluster2.Center), cluster1.points.ToList().Union(cluster2.points).ToList())); }