public PointCloudVertices AlignPointClouds_OneVector(PointCloudVertices pointCloudSource, PointCloudVertices pointCloudTarget, int vectorNumberSource, int vectorNumberTarget) { //------------------- pointCloudSourceCentered = CalculatePCA_Internal(pointCloudSource); //second object: //----------- pointCloudTargetCentered = CalculatePCA_Internal(pointCloudTarget); //Vector3d v = TargetPCVectors[vectorNumberTarget]; //v.X = -v.X; //v.Y = -v.Y; //v.Z = -v.Z; //TargetPCVectors[vectorNumberTarget] = v; Matrix3d R = new Matrix3d(); //R = R.RotationOneVectorToAnother(TargetPCVectors[vectorNumber], SourcePCVectors[vectorNumber]); R = R.RotationOneVertexToAnother(pointCloudSource.PCAAxes[vectorNumberSource], pointCloudTarget.PCAAxes[vectorNumberTarget]); //R.CheckRotationMatrix(); // //test: //Vector3d testV = R.MultiplyVector(sourceV); PointCloudVertices pointCloudResult = PointCloudVertices.CopyVertices(pointCloudSource); PointCloudVertices.SubtractVectorRef(pointCloudResult, pointCloudSource.CentroidVector); PointCloudVertices.Rotate(pointCloudResult, R); PointCloudVertices.AddVector(pointCloudResult, pointCloudTarget.CentroidVector); pointCloudResultCentered = CalculatePCA_Internal(pointCloudResult); MeanDistance = PointCloudVertices.MeanDistance(pointCloudResult, pointCloudTarget); System.Diagnostics.Debug.WriteLine("-->> PCA (V) - Mean Distance : " + MeanDistance.ToString("0.000000")); return(pointCloudResult); }