edge_lengths.cpp 1023 B

1234567891011121314151617181920212223
  1. #include "edge_lengths.h"
  2. template <typename DerivedV, typename DerivedF, typename DerivedL>
  3. IGL_INLINE void igl::edge_lengths(
  4. const Eigen::PlainObjectBase<DerivedV>& V,
  5. const Eigen::PlainObjectBase<DerivedF>& F,
  6. Eigen::PlainObjectBase<DerivedL>& L)
  7. {
  8. assert(F.cols() == 3);
  9. L.resize(F.rows(),3);
  10. // loop over faces
  11. for(int i = 0;i<F.rows();i++)
  12. {
  13. L(i,0) = sqrt((V.row(F(i,1))-V.row(F(i,2))).array().pow(2).sum());
  14. L(i,1) = sqrt((V.row(F(i,2))-V.row(F(i,0))).array().pow(2).sum());
  15. L(i,2) = sqrt((V.row(F(i,0))-V.row(F(i,1))).array().pow(2).sum());
  16. }
  17. }
  18. #ifndef IGL_HEADER_ONLY
  19. // Explicit template specialization
  20. template void igl::edge_lengths<Eigen::Matrix<double, -1, -1, 0, -1, -1>, Eigen::Matrix<int, -1, -1, 0, -1, -1>, Eigen::Matrix<double, -1, -1, 0, -1, -1> >(Eigen::PlainObjectBase<Eigen::Matrix<double, -1, -1, 0, -1, -1> > const&, Eigen::PlainObjectBase<Eigen::Matrix<int, -1, -1, 0, -1, -1> > const&, Eigen::PlainObjectBase<Eigen::Matrix<double, -1, -1, 0, -1, -1> >&);
  21. #endif