浏览代码

patch rsqrt in SVD code

Former-commit-id: 2bfed2df6022c07db092622d1a202ee368173a6d
Alec Jacobson (jalec 11 年之前
父节点
当前提交
3f789688b2
共有 3 个文件被更改,包括 55 次插入3 次删除
  1. 2 2
      include/igl/embree/EmbreeIntersector.h
  2. 34 0
      include/igl/lbs_matrix.cpp
  3. 19 1
      include/igl/lbs_matrix.h

+ 2 - 2
include/igl/embree/EmbreeIntersector.h

@@ -162,13 +162,13 @@ inline igl::EmbreeIntersector::EmbreeIntersector()
 }
 
 inline igl::EmbreeIntersector::EmbreeIntersector(
-  const EmbreeIntersector & that)
+  const EmbreeIntersector & /*that*/)
 {
   assert(false && "Copying EmbreeIntersector is not allowed");
 }
 
 inline igl::EmbreeIntersector igl::EmbreeIntersector::operator=(
-  const EmbreeIntersector & that)
+  const EmbreeIntersector & /*that*/)
 {
   assert(false && "Assigning an EmbreeIntersector is not allowed");
   return *this;

+ 34 - 0
include/igl/lbs_matrix.cpp

@@ -141,3 +141,37 @@ IGL_INLINE void igl::lbs_matrix(
   lbs_matrix(V,W,WI,sM);
   M = MatrixXd(sM);
 }
+
+IGL_INLINE void igl::lbs_matrix(
+  const Eigen::MatrixXd & V, 
+  const Eigen::MatrixXd & W,
+  Eigen::MatrixXd & M)
+{
+  using namespace Eigen;
+  // Number of dimensions
+  const int dim = V.cols();
+  // Number of model points
+  const int n = V.rows();
+  // Number of skinning transformations/weights
+  const int m = W.cols();
+
+  // Assumes that first n rows of weights correspond to V
+  assert(W.rows() >= n);
+
+  M.resize(n,(dim+1)*m);
+  for(int j = 0;j<m;j++)
+  {
+    VectorXd Wj = W.block(0,j,V.rows(),1);
+    for(int i = 0;i<(dim+1);i++)
+    {
+      if(i<dim)
+      {
+        M.col(i + j*(dim+1)) = 
+          Wj.cwiseProduct(V.col(i));
+      }else
+      {
+        M.col(i + j*(dim+1)).array() = W.block(0,j,V.rows(),1).array();
+      }
+    }
+  }
+}

+ 19 - 1
include/igl/lbs_matrix.h

@@ -32,7 +32,6 @@ namespace igl
   //       reshape(permute(Astack,[3 1 2]),n*dim*(dim+1),1)
   //     or A = [Lxx;Lyx;Lxy;Lyy;tx;ty], and likewise for other dim
   //     if Astack(:,:,i) is the dim by (dim+1) transformation at handle i
-  //
   IGL_INLINE void lbs_matrix(
     const Eigen::MatrixXd & V, 
     const Eigen::MatrixXd & W,
@@ -69,6 +68,25 @@ namespace igl
     const Eigen::MatrixXd & W,
     const Eigen::MatrixXi & WI,
     Eigen::MatrixXd & M);
+  // LBS_MATRIX Linear blend skinning can be expressed by V' = M * T where V' is
+  // a #V by dim matrix of deformed vertex positions (one vertex per row), M is a
+  // #V by (dim+1)*#T (composed of weights and rest positions) and T is a
+  // #T*(dim+1) by dim matrix of #T stacked transposed transformation matrices.
+  // See equations (1) and (2) in "Fast Automatic Skinning Transformations"
+  // [Jacobson et al 2012]
+  //
+  // Inputs:
+  //   V  #V by dim list of rest positions
+  //   W  #V+ by #T  list of weights
+  // Outputs:
+  //   M  #V by #T*(dim+1)
+  //
+  // In MATLAB:
+  //   kron(ones(1,size(W,2)),[V ones(size(V,1),1)]).*kron(W,ones(1,size(V,2)+1))
+  IGL_INLINE void lbs_matrix(
+    const Eigen::MatrixXd & V, 
+    const Eigen::MatrixXd & W,
+    Eigen::MatrixXd & M);
 }
 #ifdef IGL_HEADER_ONLY
 #include "lbs_matrix.cpp"