volume.h 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. // This file is part of libigl, a simple c++ geometry processing library.
  2. //
  3. // Copyright (C) 2014 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_VOLUME_H
  9. #define IGL_VOLUME_H
  10. #include "igl_inline.h"
  11. #include <Eigen/Core>
  12. namespace igl
  13. {
  14. // VOLUME Compute volume for all tets of a given tet mesh
  15. // (V,T)
  16. //
  17. // vol = volume(V,T)
  18. //
  19. // Inputs:
  20. // V #V by dim list of vertex positions
  21. // T #V by 4 list of tet indices
  22. // Outputs:
  23. // vol #T list of dihedral angles (in radians)
  24. //
  25. template <
  26. typename DerivedV,
  27. typename DerivedT,
  28. typename Derivedvol>
  29. IGL_INLINE void volume(
  30. const Eigen::MatrixBase<DerivedV>& V,
  31. const Eigen::MatrixBase<DerivedT>& T,
  32. Eigen::PlainObjectBase<Derivedvol>& vol);
  33. template <
  34. typename DerivedA,
  35. typename DerivedB,
  36. typename DerivedC,
  37. typename DerivedD,
  38. typename Derivedvol>
  39. IGL_INLINE void volume(
  40. const Eigen::MatrixBase<DerivedA> & A,
  41. const Eigen::MatrixBase<DerivedB> & B,
  42. const Eigen::MatrixBase<DerivedC> & C,
  43. const Eigen::MatrixBase<DerivedD> & D,
  44. Eigen::PlainObjectBase<Derivedvol> & vol);
  45. // Single tet
  46. template <
  47. typename VecA,
  48. typename VecB,
  49. typename VecC,
  50. typename VecD>
  51. IGL_INLINE typename VecA::Scalar volume_single(
  52. const VecA & a,
  53. const VecB & b,
  54. const VecC & c,
  55. const VecD & d);
  56. // Intrinsic version:
  57. //
  58. // Inputs:
  59. // L #V by 6 list of edge lengths (see edge_lengths)
  60. template <
  61. typename DerivedL,
  62. typename Derivedvol>
  63. IGL_INLINE void volume(
  64. const Eigen::MatrixBase<DerivedL>& L,
  65. Eigen::PlainObjectBase<Derivedvol>& vol);
  66. }
  67. #ifndef IGL_STATIC_LIBRARY
  68. # include "volume.cpp"
  69. #endif
  70. #endif