public static double distance(HCluster clusterA, HCluster clusterB) { double dist = Math.Pow(clusterA.meanVector.X - clusterB.meanVector.X, 2) + Math.Pow(clusterA.meanVector.Y - clusterB.meanVector.Y, 2) + Math.Pow(clusterA.meanVector.Z - clusterB.meanVector.Z, 2); return(Math.Sqrt(dist)); }
//when clusters are merged, find mean vector of the two before "destoying" the previous cluster //no need to run through all inputs again internal void UpdateMean(HCluster hCluster) { meanVector = new Vector3d((meanVector.X + hCluster.meanVector.X) / 2, (meanVector.Y + hCluster.meanVector.Y) / 2, (meanVector.Z + hCluster.meanVector.Z) / 2); }
//method used when adding inputs of one cluster to another, to merge them public void AddInputs(HCluster clusterToMerge) { assignedInputs.AddRange(clusterToMerge.assignedInputs); assignedMeshes.AddRange(clusterToMerge.assignedMeshes); }