public PointCloudVertices AlignPointClouds_SVD_WithShuflleEffect(bool axesRotateEffect, PointCloudVertices pointCloudSource, PointCloudVertices pointCloudTarget) { try { if (pointCloudSource == null || pointCloudTarget == null || pointCloudSource.Count == 0 || pointCloudTarget.Count == 0) { System.Diagnostics.Debug.WriteLine("PCA - please check point clouds "); return(null); } this.Matrix = Matrix4d.Identity; pointCloudSourceCentered = CalculatePCA_Internal(pointCloudSource); PrepareTargetTree(pointCloudTarget); PointCloudVertices myPointCloudIteration = PointCloudVertices.CloneVertices(pointCloudSource); for (int i = 0; i < MaxmimumIterations; i++) { double meanDistance = SVD_Iteration(myPointCloudIteration); System.Diagnostics.Debug.WriteLine("-->> Iteration " + i.ToString() + " : Mean Distance : " + meanDistance.ToString("G") + ": duration: " + GlobalVariables.TimeSpanString()); if (meanDistance < thresholdConvergence) { break; } myPointCloudIteration = pointCloudResultBest; } //final check: pointCloudResultCentered = CalculatePCA_Internal(pointCloudResult); //"Shuffle" effect - the target points are in other order after kdtree search: //The mean distance calculated again, as check (was calculated before in the kdTree routine) MeanDistance = PointCloudVertices.MeanDistance(pointCloudResult, pointCloudTargetKDTree); System.Diagnostics.Debug.WriteLine("-->> TO CHECK: PCA (SVD) - Final Mean Distance : " + MeanDistance.ToString("G")); //MeanDistance = PointCloudVertices.MeanDistance(pointCloudResult, pointCloudTarget); //System.Diagnostics.Debug.WriteLine("-->> PCA (SVD) - Final Mean Distance : " + MeanDistance.ToString("G")); this.Matrix = AdjustSourceTargetByTranslation(Matrix, pointCloudSource, pointCloudTarget); pointCloudResult = Matrix.TransformPoints(pointCloudSource); pointCloudResultCentered = CalculatePCA_Internal(pointCloudResult); //MeanDistance = PointCloudVertices.MeanDistance(pointCloudResult, pointCloudTarget); //System.Diagnostics.Debug.WriteLine("-->> PCA (SVD) - Final Mean Distance : " + MeanDistance.ToString("G")); //for display later: } catch { System.Windows.Forms.MessageBox.Show("Error aligning point cloud"); } return(pointCloudResult); }
public static void ShowLastTimeSpan(string name) { System.Diagnostics.Debug.WriteLine("--Duration for " + name + " : " + GlobalVariables.TimeSpanString()); }