edge_lengths.h 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. // This file is part of libigl, a simple c++ geometry processing library.
  2. //
  3. // Copyright (C) 2013 Alec Jacobson <alecjacobson@gmail.com>
  4. //
  5. // This Source Code Form is subject to the terms of the Mozilla Public License
  6. // v. 2.0. If a copy of the MPL was not distributed with this file, You can
  7. // obtain one at http://mozilla.org/MPL/2.0/.
  8. #ifndef IGL_EDGE_LENGTHS_H
  9. #define IGL_EDGE_LENGTHS_H
  10. #include "igl_inline.h"
  11. #include <Eigen/Dense>
  12. namespace igl
  13. {
  14. // Constructs a list of lengths of edges opposite each index in a face
  15. // (triangle/tet) list
  16. //
  17. // Templates:
  18. // DerivedV derived from vertex positions matrix type: i.e. MatrixXd
  19. // DerivedF derived from face indices matrix type: i.e. MatrixXi
  20. // DerivedL derived from edge lengths matrix type: i.e. MatrixXd
  21. // Inputs:
  22. // V eigen matrix #V by 3
  23. // F #F by 2 list of mesh edges
  24. // or
  25. // F #F by 3 list of mesh faces (must be triangles)
  26. // or
  27. // T #T by 4 list of mesh elements (must be tets)
  28. // Outputs:
  29. // L #F by {1|3|6} list of edge lengths
  30. // for edges, column of lengths
  31. // for triangles, columns correspond to edges [1,2],[2,0],[0,1]
  32. // for tets, columns correspond to edges
  33. // [3 0],[3 1],[3 2],[1 2],[2 0],[0 1]
  34. //
  35. template <typename DerivedV, typename DerivedF, typename DerivedL>
  36. IGL_INLINE void edge_lengths(
  37. const Eigen::PlainObjectBase<DerivedV>& V,
  38. const Eigen::PlainObjectBase<DerivedF>& F,
  39. Eigen::PlainObjectBase<DerivedL>& L);
  40. }
  41. #ifndef IGL_STATIC_LIBRARY
  42. # include "edge_lengths.cpp"
  43. #endif
  44. #endif