Эх сурвалжийг харах

min_quad_with_fixed and active_set now take H2 instead of H

Former-commit-id: 5e729fdba10328518a88216afd1da6921dd1a714
Alec Jacobson 11 жил өмнө
parent
commit
4de74a0772

+ 2 - 1
build/Makefile_svd3x3

@@ -12,7 +12,8 @@ CFLAGS += $(OPTFLAGS) -std=c++11
 .PHONY: libiglsvd3x3
 libiglsvd3x3: obj ../lib/libiglsvd3x3.a
 
-CPP_FILES=$(wildcard ../include/igl/svd3x3/*.cpp)
+SRC_DIR=../include/igl/svd3x3/
+CPP_FILES=$(wildcard $(SRC_DIR)*.cpp)
 OBJ_FILES=$(addprefix obj/,$(notdir $(CPP_FILES:.cpp=.o)))
 
 # include igl headers

+ 1 - 1
include/igl/active_set.cpp

@@ -297,7 +297,7 @@ IGL_INLINE igl::SolverStatus igl::active_set(
     slice(A,known_i,1,Ak);
     Eigen::PlainObjectBase<DerivedB> Bk;
     slice(B,known_i,Bk);
-    MatrixXd Lambda_known_i = -(Ak*Z + 0.5*Bk);
+    MatrixXd Lambda_known_i = -(0.5*Ak*Z + 0.5*Bk);
     // reverse the lambda values for lx
     Lambda_known_i.block(nk,0,as_lx_count,1) = 
       (-1*Lambda_known_i.block(nk,0,as_lx_count,1)).eval();

+ 4 - 1
include/igl/active_set.h

@@ -20,7 +20,10 @@ namespace igl
   // using QR decomposition otherwise:
   //   http://www.okstate.edu/sas/v8/sashtml/ormp/chap5/sect32.htm
   //
-  // ACTIVE_SET Minimize quadratic energy Z'*A*Z + Z'*B + C with constraints
+  // ACTIVE_SET Minimize quadratic energy 
+  //
+  // 0.5*Z'*A*Z + Z'*B + C with constraints
+  //
   // that Z(known) = Y, optionally also subject to the constraints Aeq*Z = Beq,
   // and further optionally subject to the linear inequality constraints that
   // Aieq*Z <= Bieq and constant inequality constraints lx <= x <= ux

+ 14 - 14
include/igl/embree/project_mesh.cpp

@@ -14,20 +14,20 @@
 #include <igl/per_vertex_normals.h>
 #include <igl/embree/EmbreeIntersector.h>
 
-template <typename ScalarMatrix, typename IndexMatrix>
-IGL_INLINE ScalarMatrix igl::project_mesh(
-   const ScalarMatrix & V_source,
-   const IndexMatrix  & F_source,
-   const ScalarMatrix & V_target,
-   const IndexMatrix  & F_target
-)
-{
-  // Compute normals for the tri
-  Eigen::MatrixXd ray_dir;
-  igl::per_vertex_normals(V_source, F_source, ray_dir);
-
-  return project_points_on_mesh(V_source,ray_dir,V_target,F_target);
-}
+//template <typename ScalarMatrix, typename IndexMatrix>
+//IGL_INLINE ScalarMatrix igl::project_mesh(
+//   const ScalarMatrix & V_source,
+//   const IndexMatrix  & F_source,
+//   const ScalarMatrix & V_target,
+//   const IndexMatrix  & F_target
+//)
+//{
+//  // Compute normals for the tri
+//  Eigen::MatrixXd ray_dir;
+//  igl::per_vertex_normals(V_source, F_source, ray_dir);
+//
+//  return project_points_on_mesh(V_source,ray_dir,V_target,F_target);
+//}
 
 template <typename ScalarMatrix, typename IndexMatrix>
 IGL_INLINE ScalarMatrix igl::project_points_on_mesh

+ 24 - 24
include/igl/embree/project_mesh.h

@@ -16,30 +16,30 @@
 namespace igl 
 {
 
-  // Project the triangle mesh V_source, F_source onto the triangle mesh
-  // V_target,F_target.
-  // A ray is casted for every vertex in the normal direction and its opposite.
-  //
-  // Input:
-  // V_source: #Vx3 Vertices of the source mesh
-  // F_source: #Fx3 Faces of the source mesh
-  // V_target: #V2x3 Vertices of the target mesh
-  // F_target: #F2x3 Faces of the target mesh
-  //
-  // Output:
-  // #Vx3 matrix of baricentric coordinate. Each row corresponds to 
-  // a vertex of the projected mesh and it has the following format:
-  // id b1 b2. id is the id of a face of the source mesh. b1 and b2 are 
-  // the barycentric coordinates wrt the first two edges of the triangle
-  // To convert to standard global coordinates, see barycentric2global.h
-  template <typename ScalarMatrix, typename IndexMatrix>
-  IGL_INLINE ScalarMatrix project_mesh
-  (
-		const ScalarMatrix & V_source,
-  	const IndexMatrix  & F_source,
-    const ScalarMatrix & V_target,
-    const IndexMatrix  & F_target
-	);
+  //// Project the triangle mesh V_source, F_source onto the triangle mesh
+  //// V_target,F_target.
+  //// A ray is casted for every vertex in the normal direction and its opposite.
+  ////
+  //// Input:
+  //// V_source: #Vx3 Vertices of the source mesh
+  //// F_source: #Fx3 Faces of the source mesh
+  //// V_target: #V2x3 Vertices of the target mesh
+  //// F_target: #F2x3 Faces of the target mesh
+  ////
+  //// Output:
+  //// #Vx3 matrix of baricentric coordinate. Each row corresponds to 
+  //// a vertex of the projected mesh and it has the following format:
+  //// id b1 b2. id is the id of a face of the source mesh. b1 and b2 are 
+  //// the barycentric coordinates wrt the first two edges of the triangle
+  //// To convert to standard global coordinates, see barycentric2global.h
+  //template <typename ScalarMatrix, typename IndexMatrix>
+  //IGL_INLINE ScalarMatrix project_mesh
+  //(
+	//	const ScalarMatrix & V_source,
+  //	const IndexMatrix  & F_source,
+  //  const ScalarMatrix & V_target,
+  //  const IndexMatrix  & F_target
+	//);
 
   // Project the point cloud V_source onto the triangle mesh
   // V_target,F_target. 

+ 1 - 1
include/igl/lscm.cpp

@@ -45,7 +45,7 @@ IGL_INLINE void igl::lscm(
   }
   
   // Minimize the LSCM energy
-  SparseMatrix<double> Q = -0.5*L_flat + A;
+  SparseMatrix<double> Q = -L_flat + 2.*A;
   const VectorXd B_flat = VectorXd::Zero(V.rows()*2);
   igl::min_quad_with_fixed_data<double> data;
   igl::min_quad_with_fixed_precompute(Q,b_flat,SparseMatrix<double>(),true,data);

+ 2 - 1
include/igl/min_quad_with_fixed.cpp

@@ -28,7 +28,7 @@
 
 template <typename T, typename Derivedknown>
 IGL_INLINE bool igl::min_quad_with_fixed_precompute(
-  const Eigen::SparseMatrix<T>& A,
+  const Eigen::SparseMatrix<T>& A2,
   const Eigen::PlainObjectBase<Derivedknown> & known,
   const Eigen::SparseMatrix<T>& Aeq,
   const bool pd,
@@ -39,6 +39,7 @@ IGL_INLINE bool igl::min_quad_with_fixed_precompute(
   using namespace Eigen;
   using namespace std;
   using namespace igl;
+  const Eigen::SparseMatrix<T> A = 0.5*A2;
 #ifdef MIN_QUAD_WITH_FIXED_CPP_DEBUG
   cout<<"    pre"<<endl;
 #endif

+ 4 - 1
include/igl/min_quad_with_fixed.h

@@ -25,7 +25,10 @@ namespace igl
   // QR decomposition otherwise:
   //   http://www.okstate.edu/sas/v8/sashtml/ormp/chap5/sect32.htm
   //
-  // MIN_QUAD_WITH_FIXED Minimize quadratic energy Z'*A*Z + Z'*B + C with
+  // MIN_QUAD_WITH_FIXED Minimize quadratic energy 
+  //
+  // 0.5*Z'*A*Z + Z'*B + C with
+  //
   // constraints that Z(known) = Y, optionally also subject to the constraints
   // Aeq*Z = Beq
   //

+ 2 - 2
include/igl/svd3x3/arap.cpp

@@ -147,7 +147,7 @@ IGL_INLINE bool igl::arap_precomputation(
   }
   assert(data.K.rows() == data.n*data.dim);
 
-  SparseMatrix<double> Q = (-0.5*L).eval();
+  SparseMatrix<double> Q = (-L).eval();
 
   if(data.with_dynamics)
   {
@@ -155,7 +155,7 @@ IGL_INLINE bool igl::arap_precomputation(
     assert(h != 0);
     SparseMatrix<double> M;
     massmatrix(V,F,MASSMATRIX_TYPE_DEFAULT,data.M);
-    SparseMatrix<double> DQ = 0.5/(h*h)*data.M;
+    SparseMatrix<double> DQ = 1./(h*h)*data.M;
     Q += DQ;
     // Dummy external forces
     data.f_ext = MatrixXd::Zero(n,data.dim);