From eee48d7b16c1cbe710156f714876e2c6f9dfe3bb Mon Sep 17 00:00:00 2001 From: Yihuan Mao Date: Sun, 7 Oct 2018 00:05:35 -0400 Subject: [PATCH] Yihuan Mao submission --- main.cpp | 2 +- src/cotmatrix.cpp | 25 ++++++++++++++++++++++++- src/massmatrix.cpp | 14 +++++++++++++- src/smooth.cpp | 24 ++++++++++++++++++++++-- 4 files changed, 60 insertions(+), 5 deletions(-) diff --git a/main.cpp b/main.cpp index c1d5fed..e9401d5 100644 --- a/main.cpp +++ b/main.cpp @@ -14,7 +14,7 @@ int main(int argc, char *argv[]) Eigen::MatrixXi F; double lambda = 1e-5; igl::read_triangle_mesh( - (argc>1?argv[1]:"../shared/data/bunny.off"),OV,F); + (argc>1?argv[1]:"../shared/data/decimated-knight.off"),OV,F); // Load data into MatrixXd rather than VectorXd for simpler `smooth` API // Just use y-coordinates as data to be smoothed Eigen::MatrixXd G = OV.col(1); diff --git a/src/cotmatrix.cpp b/src/cotmatrix.cpp index c888e5c..ecdbb28 100644 --- a/src/cotmatrix.cpp +++ b/src/cotmatrix.cpp @@ -1,10 +1,33 @@ #include "cotmatrix.h" +#include "math.h" + +double cot(double a,double b,double c){ + double s=(a+b+c)/2; + double area=sqrt(s*(s-a)*(s-b)*(s-c)); + double sin=area*2/b/c; + double cos=(b*b+c*c-a*a)/2/b/c; + return cos/sin; +} void cotmatrix( const Eigen::MatrixXd & l, const Eigen::MatrixXi & F, Eigen::SparseMatrix & L) { - // Add your code here + L.resize(F.maxCoeff()+1,F.maxCoeff()+1); + int f=F.rows(); + double c; + typedef Eigen::Triplet T; + std::vector list; + for (int i=0; i & M) { - // Add your code here + int f=F.rows(); + M.resize(F.maxCoeff()+1); + Eigen::VectorXd area=Eigen::VectorXd::Zero(F.maxCoeff()+1); + double s,a; + for (int i=0; i +#include +#include "massmatrix.h" +#include "cotmatrix.h" void smooth( const Eigen::MatrixXd & V, @@ -7,6 +11,22 @@ void smooth( double lambda, Eigen::MatrixXd & U) { - // Replace with your code - U = G; + Eigen::MatrixXd l; + Eigen::SparseMatrix L,A; + Eigen::DiagonalMatrix M; + igl::edge_lengths(V, F, l); + cotmatrix(l,F,L); + massmatrix(l,F,M); + Eigen::MatrixXd b=M*G; + typedef Eigen::Triplet T; + std::vector list; + Eigen::VectorXd M1=M.diagonal(); + for (int i=0; i> solver; + solver.compute(A); + U=solver.solve(b); }