avg_edge_length.cpp 664 B

12345678910111213141516171819202122232425262728293031323334353637
  1. #include "read_eigen_from_CSV.h"
  2. #include <sstream>
  3. #include <string>
  4. #include <fstream>
  5. #include <vector>
  6. namespace igl
  7. {
  8. template <typename DerivedV, typename DerivedF>
  9. double avg_edge_length(
  10. const Eigen::PlainObjectBase<DerivedV>& V,
  11. const Eigen::PlainObjectBase<DerivedF>& F)
  12. {
  13. double avg = 0;
  14. long int count = 0;
  15. for (unsigned i=0;i<F.rows();++i)
  16. {
  17. for (unsigned j=0;j<3;++j)
  18. {
  19. ++count;
  20. avg += (V.row(F(i,j)) - V.row(F(i,(j+1)%3))).norm();
  21. }
  22. }
  23. return avg / (double) count;
  24. }
  25. }
  26. #ifndef IGL_HEADER_ONLY
  27. // Explicit template specialization
  28. // generated by autoexplicit.sh
  29. #endif