浏览代码

arap dynamics, better parameters

Former-commit-id: a2e3caea0f6bdfee3886238a4eb4cb04309f0e0e
Alec Jacobson 10 年之前
父节点
当前提交
f318d4eed6
共有 4 个文件被更改,包括 8 次插入4 次删除
  1. 0 1
      include/igl/AABB.h
  2. 1 1
      include/igl/ARAPEnergyType.h
  3. 4 2
      include/igl/arap.cpp
  4. 3 0
      include/igl/arap.h

+ 0 - 1
include/igl/AABB.h

@@ -1037,7 +1037,6 @@ inline void igl::AABB<DerivedV,DIM>::leaf_squared_distance(
   }
   const auto & point_point_squared_distance = [&](const RowVectorDIMS & s)
   {
-    cout<<"pp"<<endl;
     const Scalar sqr_d_s = (p-s).squaredNorm();
     set_min(p,sqr_d_s,m_primitive,s,sqr_d,i,c);
   };

+ 1 - 1
include/igl/ARAPEnergyType.h

@@ -22,7 +22,7 @@ namespace igl
   //       deformation" by [Chao et al.  2010], rotations defined at elements
   //       (triangles or tets) 
   //     ARAP_ENERGY_TYPE_DEFAULT  Choose one automatically: spokes and rims
-  //       for surfaces, elements for planar meshes and test (not fully
+  //       for surfaces, elements for planar meshes and tets (not fully
   //       supported)
   enum ARAPEnergyType
   {

+ 4 - 2
include/igl/arap.cpp

@@ -153,7 +153,8 @@ IGL_INLINE bool igl::arap_precomputation(
     assert(h != 0);
     SparseMatrix<double> M;
     massmatrix(V,F,MASSMATRIX_TYPE_DEFAULT,data.M);
-    SparseMatrix<double> DQ = 1./(h*h)*data.M;
+    const double dw = (1./data.ym)*(h*h);
+    SparseMatrix<double> DQ = dw * 1./(h*h)*data.M;
     Q += DQ;
     // Dummy external forces
     data.f_ext = MatrixXd::Zero(n,data.dim);
@@ -268,7 +269,8 @@ IGL_INLINE bool igl::arap_solve(
       // h*data.vel = (V0-Vm1)
       // -h*data.vel = -V0+Vm1)
       // -V0-h*data.vel = -2V0+Vm1
-      Dl = 1./(h*h)*data.M*(-U0 - h*data.vel) - data.f_ext;
+      const double dw = (1./data.ym)*(h*h);
+      Dl = dw * (1./(h*h)*data.M*(-U0 - h*data.vel) - data.f_ext);
     }
 
     VectorXd Rcol;

+ 3 - 0
include/igl/arap.h

@@ -26,6 +26,7 @@ namespace igl
     // f_ext  #V by dim list of external forces
     // vel  #V by dim list of velocities
     // h  dynamics time step
+    // ym  ~Young's modulus smaller is softer, larger is more rigid/stiff
     // max_iter  maximum inner iterations
     // K  rhs pre-multiplier
     // M  mass matrix
@@ -38,6 +39,7 @@ namespace igl
     bool with_dynamics;
     Eigen::MatrixXd f_ext,vel;
     double h;
+    double ym;
     int max_iter;
     Eigen::SparseMatrix<double> K,M;
     Eigen::SparseMatrix<double> CSM;
@@ -51,6 +53,7 @@ namespace igl
         with_dynamics(false),
         f_ext(),
         h(1),
+        ym(1),
         max_iter(10),
         K(),
         CSM(),