scalar_to_cr_vector_gradient.h 3.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. // This file is part of libigl, a simple c++ geometry processing library.
  2. //
  3. // Copyright (C) 2020 Oded Stein <[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_SCALAR_TO_CR_VECTOT_GRADIENT_H
  9. #define IGL_SCALAR_TO_CR_VECTOT_GRADIENT_H
  10. #include "igl_inline.h"
  11. #include <Eigen/Core>
  12. #include <Eigen/Sparse>
  13. namespace igl
  14. {
  15. /// Computes the gradient matrix with hat functions on the right, and vector
  16. /// CR functions on the left. See Oded Stein, Max Wardetzky, Alec Jacobson,
  17. /// Eitan Grinspun, 2020. "A Simple Discretization of the Vector Dirichlet
  18. /// Energy"
  19. ///
  20. /// @param[in] V #V by dim list of vertex positions
  21. /// @param[in] F #F by 3/4 list of triangle/tetrahedron indices
  22. /// @param[in] E #F by 3 a mapping from each halfedge to each edge
  23. /// @param[in] oE #F by 3 the orientation (e.g., -1 or 1) of each halfedge
  24. /// @param[out] G 2*|HE| by #V gradient matrix
  25. template <typename DerivedV, typename DerivedF, typename DerivedE,
  26. typename DerivedOE, typename ScalarG>
  27. IGL_INLINE void
  28. scalar_to_cr_vector_gradient(
  29. const Eigen::MatrixBase<DerivedV>& V,
  30. const Eigen::MatrixBase<DerivedF>& F,
  31. const Eigen::MatrixBase<DerivedE>& E,
  32. const Eigen::MatrixBase<DerivedOE>& oE,
  33. Eigen::SparseMatrix<ScalarG>& G);
  34. /// \overload
  35. /// @param[out] E #F by 3 a mapping from each halfedge to each edge
  36. /// @param[out] oE #F by 3 the orientation (e.g., -1 or 1) of each halfedge
  37. template <typename DerivedV, typename DerivedF, typename DerivedE,
  38. typename DerivedOE, typename ScalarG>
  39. IGL_INLINE void
  40. scalar_to_cr_vector_gradient(
  41. const Eigen::MatrixBase<DerivedV>& V,
  42. const Eigen::MatrixBase<DerivedF>& F,
  43. Eigen::PlainObjectBase<DerivedE>& E,
  44. Eigen::PlainObjectBase<DerivedOE>& oE,
  45. Eigen::SparseMatrix<ScalarG>& G);
  46. /// \overload
  47. /// \brief intrinsic version.
  48. ///
  49. /// @param[in] l_sq #F by 3 list of squared edge lengths of each halfedge
  50. /// @param[in] dA #F list of double areas
  51. ///
  52. /// \fileinfo
  53. template <typename DerivedF, typename DerivedL_sq, typename DeriveddA,
  54. typename DerivedE, typename DerivedOE, typename ScalarG>
  55. IGL_INLINE void scalar_to_cr_vector_gradient_intrinsic(
  56. const Eigen::MatrixBase<DerivedF>& F,
  57. const Eigen::MatrixBase<DerivedL_sq>& l_sq,
  58. const Eigen::MatrixBase<DeriveddA>& dA,
  59. const Eigen::MatrixBase<DerivedE>& E,
  60. const Eigen::MatrixBase<DerivedOE>& oE,
  61. Eigen::SparseMatrix<ScalarG>& G);
  62. /// \overload
  63. /// \fileinfo
  64. template <typename DerivedF, typename DerivedL_sq, typename DerivedE,
  65. typename DerivedOE, typename ScalarG>
  66. IGL_INLINE void scalar_to_cr_vector_gradient_intrinsic(
  67. const Eigen::MatrixBase<DerivedF>& F,
  68. const Eigen::MatrixBase<DerivedL_sq>& l_sq,
  69. const Eigen::MatrixBase<DerivedE>& E,
  70. const Eigen::MatrixBase<DerivedOE>& oE,
  71. Eigen::SparseMatrix<ScalarG>& G);
  72. }
  73. #ifndef IGL_STATIC_LIBRARY
  74. # include "scalar_to_cr_vector_gradient.cpp"
  75. #endif
  76. #endif