public void SolvePhase2() { Debug.Log("Phase 2 Starting..."); int nRow = 9 * (triAdj.adjacentTriangleCount + srcMesh.NumberOfTriangles) + 3 * (vertexInfo.numberFree); int nCol = 3 * (vertexInfo.numberFree + srcMesh.NumberOfTriangles); Debug.Log(String.Format("Rows : {0} \n Cols : {1}", nRow, nCol)); Matrix <float> A; Vector <float> C; for (float wt = wtClosestStart; wt < wtClosestEnd; wt += wtClosestStep) { Debug.Log("Iteration Step " + wt); Debug.Log("Creating Correspondence map.."); var correspondenceMap = ClosestPoint.CreateCorrespondenceMap_Basic(srcMesh, tgtMesh); A = Matrix <float> .Build.Sparse(nRow, nCol, 0); C = Vector <float> .Build.Dense(nRow, 1); Debug.Log("Building Equations"); BuildPhase2Equation(A, C, correspondenceMap, wt); Debug.Log("Linear System Solve..."); //Debug.Log("A : " + A.ToString()); //Debug.Log("C : " + C.ToString()); var x = A.Transpose().Multiply(A).Cholesky().Solve(A.Transpose().Multiply(C)); Debug.Log("Applying Deformation...."); ApplyDeformationToSourceMesh(x); } }
public int BuildPhase2Equation(Matrix <float> A, Vector <float> C, int[] correspondenceMap, float wtClosestPoint) { int rowIdx = 0; rowIdx = BuildPhase1Equation(A, C); rowIdx = ClosestPoint.CreateClosestPointEquation(A, C, correspondenceMap, this, rowIdx, wtClosestPoint); return(rowIdx); }