Example #1
0
        public SparseMatrixComplex BuildEnergy()
        {
            //Build Laplace matrix
            SparseMatrixDouble d0    = DECDouble.Instance.BuildExteriorDerivative0Form(mesh);;
            SparseMatrixDouble star1 = DECDouble.Instance.BuildHodgeStar1Form(mesh);
            SparseMatrixDouble L     = d0.Transpose() * star1 * d0;

            SparseMatrixComplex A = SparseMatrixComplex.Copy(ref L);

            //Iterate faces
            foreach (TriMesh.Face face in mesh.Faces)
            {
                //Iterate each halfedge in face
                foreach (TriMesh.HalfEdge hf in face.Halfedges)
                {
                    int i = hf.ToVertex.Index;
                    int j = hf.FromVertex.Index;

                    Complex value = 0.5 * DDGConstant;

                    A[i, j] -= value;
                    A[j, i] += value;
                }
            }


            return(A);
        }