Răsfoiți Sursa

lbs_matrix overloads for different style output

Former-commit-id: d0ad87e2c27b6eb554b8a1a6d89d41d9dcc47ee3
Alec Jacobson (jalec 11 ani în urmă
părinte
comite
fddb3d6563

+ 38 - 38
include/igl/lbs_matrix.cpp

@@ -1,6 +1,40 @@
 #include "lbs_matrix.h"
 
 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();
+      }
+    }
+  }
+}
+
+IGL_INLINE void igl::lbs_matrix_column(
   const Eigen::MatrixXd & V, 
   const Eigen::MatrixXd & W,
   Eigen::SparseMatrix<double>& M)
@@ -41,7 +75,7 @@ IGL_INLINE void igl::lbs_matrix(
   M.makeCompressed();
 }
 
-IGL_INLINE void igl::lbs_matrix(
+IGL_INLINE void igl::lbs_matrix_column(
   const Eigen::MatrixXd & V, 
   const Eigen::MatrixXd & W,
   Eigen::MatrixXd & M)
@@ -79,7 +113,7 @@ IGL_INLINE void igl::lbs_matrix(
   }
 }
 
-IGL_INLINE void igl::lbs_matrix(
+IGL_INLINE void igl::lbs_matrix_column(
   const Eigen::MatrixXd & V, 
   const Eigen::MatrixXd & W,
   const Eigen::MatrixXi & WI,
@@ -129,7 +163,7 @@ IGL_INLINE void igl::lbs_matrix(
 }
 
 
-IGL_INLINE void igl::lbs_matrix(
+IGL_INLINE void igl::lbs_matrix_column(
   const Eigen::MatrixXd & V, 
   const Eigen::MatrixXd & W,
   const Eigen::MatrixXi & WI,
@@ -138,40 +172,6 @@ IGL_INLINE void igl::lbs_matrix(
   // Cheapskate wrapper
   using namespace Eigen;
   SparseMatrix<double> sM;
-  lbs_matrix(V,W,WI,sM);
+  lbs_matrix_column(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();
-      }
-    }
-  }
-}

+ 23 - 23
include/igl/lbs_matrix.h

@@ -14,6 +14,25 @@
 
 namespace igl
 {
+  // 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);
   // LBS_MATRIX  construct a matrix that when multiplied against a column of
   // affine transformation entries computes new coordinates of the vertices
   //
@@ -32,11 +51,11 @@ 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(
+  IGL_INLINE void lbs_matrix_column(
     const Eigen::MatrixXd & V, 
     const Eigen::MatrixXd & W,
     Eigen::SparseMatrix<double>& M);
-  IGL_INLINE void lbs_matrix(
+  IGL_INLINE void lbs_matrix_column(
     const Eigen::MatrixXd & V, 
     const Eigen::MatrixXd & W,
     Eigen::MatrixXd & M);
@@ -58,35 +77,16 @@ namespace igl
   //     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(
+  IGL_INLINE void lbs_matrix_column(
     const Eigen::MatrixXd & V, 
     const Eigen::MatrixXd & W,
     const Eigen::MatrixXi & WI,
     Eigen::SparseMatrix<double>& M);
-  IGL_INLINE void lbs_matrix(
+  IGL_INLINE void lbs_matrix_column(
     const Eigen::MatrixXd & V, 
     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"

+ 9 - 4
include/igl/svd3x3/arap_dof.cpp

@@ -340,11 +340,16 @@ namespace igl
     return mD;
   }
   
-  // converts CSM_M_SSCALAR[0], CSM_M_SSCALAR[1], CSM_M_SSCALAR[2] into one "condensed" matrix CSM while checking we're not 
-  // loosing any information by this process; specifically, returns maximal difference from scaled 3x3 identity blocks,
-  // which should be pretty small number
+  // converts CSM_M_SSCALAR[0], CSM_M_SSCALAR[1], CSM_M_SSCALAR[2] into one
+  // "condensed" matrix CSM while checking we're not loosing any information by
+  // this process; specifically, returns maximal difference from scaled 3x3
+  // identity blocks, which should be pretty small number
   template <typename MatrixXS>
-  static typename MatrixXS::Scalar condense_CSM(const std::vector<MatrixXS> &CSM_M_SSCALAR, int numBones, int dim, MatrixXS &CSM)
+  static typename MatrixXS::Scalar condense_CSM(
+    const std::vector<MatrixXS> &CSM_M_SSCALAR, 
+    int numBones, 
+    int dim, 
+    MatrixXS &CSM)
   {
     const int numRows = CSM_M_SSCALAR[0].rows();
     assert(CSM_M_SSCALAR[0].cols() == dim*(dim+1)*numBones);

+ 2 - 2
include/igl/svd3x3/arap_dof.h

@@ -82,7 +82,7 @@ namespace igl
   //     arap_dof_update
   // Returns true on success, false on error
   //
-  // See also: lbs_matrix
+  // See also: lbs_matrix_column
   template <typename LbsMatrixType, typename SSCALAR>
   IGL_INLINE bool arap_dof_precomputation(
     const Eigen::MatrixXd & V, 
@@ -111,7 +111,7 @@ namespace igl
   //     arap_dof_update
   // Returns true on success, false on error
   //
-  // See also: lbs_matrix
+  // See also: lbs_matrix_column
   template <typename LbsMatrixType, typename SSCALAR>
   IGL_INLINE bool arap_dof_recomputation(
     const Eigen::Matrix<int,Eigen::Dynamic,1> & fixed_dim,