moments.h 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. // This file is part of libigl, a simple c++ geometry processing library.
  2. //
  3. // Copyright (C) 2022 Alec Jacobson <[email protected]>
  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_MOMENTS_H
  9. #define IGL_MOMENTS_H
  10. #include "igl_inline.h"
  11. #include <Eigen/Core>
  12. namespace igl
  13. {
  14. /// Computes the moments of mass for a solid object bound by a triangle mesh.
  15. ///
  16. /// @param[in] V #V by 3 list of rest domain positions
  17. /// @param[in] F #F by 3 list of triangle indices into V
  18. /// @param[out] m0 zeroth moment of mass, total signed volume of solid.
  19. /// @param[out] m1 first moment of mass, center of mass (centroid) times total mass
  20. /// @param[out] m2 second moment of mass, moment of inertia with center of mass as reference point
  21. ///
  22. /// \see centroid
  23. template <
  24. typename DerivedV,
  25. typename DerivedF,
  26. typename Derivedm0,
  27. typename Derivedm1,
  28. typename Derivedm2>
  29. IGL_INLINE void moments(
  30. const Eigen::MatrixBase<DerivedV>& V,
  31. const Eigen::MatrixBase<DerivedF>& F,
  32. Derivedm0 & m0,
  33. Eigen::PlainObjectBase<Derivedm1>& m1,
  34. Eigen::PlainObjectBase<Derivedm2>& m2);
  35. }
  36. #ifndef IGL_STATIC_LIBRARY
  37. # include "moments.cpp"
  38. #endif
  39. #endif