private bool initICP() { if (TWO_MESHS_sourceObj == null || TWO_MESHS_targetObj == null) { Form_ICPMeshSelection form_Selection = new Form_ICPMeshSelection(geometryRoot); if (form_Selection.ShowDialog() != DialogResult.OK) { return(false); } TWO_MESHS_sourceObj = geometryRoot[form_Selection.source]; TWO_MESHS_targetObj = geometryRoot[form_Selection.target]; SVDLoops = form_Selection.SVDLoops; SourceSamples = form_Selection.SourceSamples; TargetSamples = form_Selection.TargetSamples; } TWO_MESHS_sourceObj.Transform = new Transform(); TWO_MESHS_targetObj.Transform = new Transform(); inputMat_source = TWO_MESHS_sourceObj.ToSampledDataMat(SourceSamples); inputMat_target = TWO_MESHS_targetObj.ToSampledDataMat(TargetSamples); //checkMat_source = TWO_MESHS_sourceObj.ToSampledDataMat(NCheck); //checkMat_target = TWO_MESHS_targetObj.ToSampledDataMat(NCheck); PCATrans_source = Utils_PCA.DoPCA(inputMat_source); PCATrans_target = Utils_PCA.DoPCA(inputMat_target); //PCATrans_source = correctPCATransform(inputMat_source, inputMat_target, PCATrans_source, PCATrans_target); PCA_InvTransMat_source = PCATrans_source.GetMatrix().Inverse() as DenseMatrix; PCA_TransMat_target = PCATrans_target.GetMatrix(); PCA_InvTransMat_target = PCA_TransMat_target.Inverse() as DenseMatrix; inputMat_source = PCA_InvTransMat_source * inputMat_source; inputMat_target = PCA_InvTransMat_target * inputMat_target; errList = new List <double>(); SVD_TransMat = DenseMatrix.CreateIdentity(4); return(true); }
private bool initSA() { if (TWO_MESHS_sourceObj == null || TWO_MESHS_targetObj == null) { Form_SAMeshSelection form_Selection = new Form_SAMeshSelection(geometryRoot); if (form_Selection.ShowDialog() != DialogResult.OK) { return(false); } TWO_MESHS_sourceObj = geometryRoot[form_Selection.source]; TWO_MESHS_targetObj = geometryRoot[form_Selection.target]; SourceSamples = form_Selection.SourceSamples; TargetSamples = form_Selection.TargetSamples; } TWO_MESHS_sourceObj.Transform = new Transform(); TWO_MESHS_targetObj.Transform = new Transform(); inputMat_source = TWO_MESHS_sourceObj.ToSampledDataMat(SourceSamples); inputMat_target = TWO_MESHS_targetObj.ToSampledDataMat_WithNormal(TargetSamples, out inputNormalMat_target); PCATrans_source = Utils_PCA.DoPCA(inputMat_source); PCATrans_target = Utils_PCA.DoPCA(inputMat_target); //PCATrans_source = correctPCATransform(inputMat_source, inputMat_target, PCATrans_source, PCATrans_target); PCA_InvTransMat_source = PCATrans_source.GetMatrix().Inverse() as DenseMatrix; PCA_TransMat_target = PCATrans_target.GetMatrix(); PCA_InvTransMat_target = PCA_TransMat_target.Inverse() as DenseMatrix; inputMat_source = PCA_InvTransMat_source * inputMat_source; inputMat_target = PCA_InvTransMat_target * inputMat_target; inputNormalMat_target = PCATrans_target.ToRotationMatrix().Inverse() * inputNormalMat_target as DenseMatrix; return(true); }