barycenter.cpp 412 B

123456789101112131415161718192021
  1. #include "barycenter.h"
  2. IGL_INLINE void igl::barycenter(
  3. const Eigen::MatrixXd & V,
  4. const Eigen::MatrixXi & F,
  5. Eigen::MatrixXd & BC)
  6. {
  7. BC.setZero(F.rows(),V.cols());
  8. // Loop over faces
  9. for(int i = 0;i<F.rows();i++)
  10. {
  11. // loop around face
  12. for(int j = 0;j<F.cols();j++)
  13. {
  14. // Accumulate
  15. BC.row(i) += V.row(F(i,j));
  16. }
  17. // average
  18. BC.row(i) /= double(F.cols());
  19. }
  20. }