harmonic.h 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122
  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_HARMONIC_H
  9. #define IGL_HARMONIC_H
  10. #include "igl_inline.h"
  11. #include <Eigen/Core>
  12. #include <Eigen/Sparse>
  13. namespace igl
  14. {
  15. // Compute k-harmonic weight functions "coordinates".
  16. //
  17. //
  18. // Inputs:
  19. // V #V by dim vertex positions
  20. // F #F by simplex-size list of element indices
  21. // b #b boundary indices into V
  22. // bc #b by #W list of boundary values
  23. // k power of harmonic operation (1: harmonic, 2: biharmonic, etc)
  24. // Outputs:
  25. // W #V by #W list of weights
  26. //
  27. template <
  28. typename DerivedV,
  29. typename DerivedF,
  30. typename Derivedb,
  31. typename Derivedbc,
  32. typename DerivedW>
  33. IGL_INLINE bool harmonic(
  34. const Eigen::MatrixBase<DerivedV> & V,
  35. const Eigen::MatrixBase<DerivedF> & F,
  36. const Eigen::MatrixBase<Derivedb> & b,
  37. const Eigen::MatrixBase<Derivedbc> & bc,
  38. const int k,
  39. Eigen::PlainObjectBase<DerivedW> & W);
  40. // Compute harmonic map using uniform laplacian operator
  41. //
  42. // Inputs:
  43. // F #F by simplex-size list of element indices
  44. // b #b boundary indices into V
  45. // bc #b by #W list of boundary values
  46. // k power of harmonic operation (1: harmonic, 2: biharmonic, etc)
  47. // Outputs:
  48. // W #V by #W list of weights
  49. //
  50. template <
  51. typename DerivedF,
  52. typename Derivedb,
  53. typename Derivedbc,
  54. typename DerivedW>
  55. IGL_INLINE bool harmonic(
  56. const Eigen::MatrixBase<DerivedF> & F,
  57. const Eigen::MatrixBase<Derivedb> & b,
  58. const Eigen::MatrixBase<Derivedbc> & bc,
  59. const int k,
  60. Eigen::PlainObjectBase<DerivedW> & W);
  61. // Compute a harmonic map using a given Laplacian and mass matrix
  62. //
  63. // Inputs:
  64. // L #V by #V discrete (integrated) Laplacian
  65. // M #V by #V mass matrix
  66. // b #b boundary indices into V
  67. // bc #b by #W list of boundary values
  68. // k power of harmonic operation (1: harmonic, 2: biharmonic, etc)
  69. // Outputs:
  70. // W #V by #V list of weights
  71. template <
  72. typename DerivedL,
  73. typename DerivedM,
  74. typename Derivedb,
  75. typename Derivedbc,
  76. typename DerivedW>
  77. IGL_INLINE bool harmonic(
  78. const Eigen::SparseMatrix<DerivedL> & L,
  79. const Eigen::SparseMatrix<DerivedM> & M,
  80. const Eigen::MatrixBase<Derivedb> & b,
  81. const Eigen::MatrixBase<Derivedbc> & bc,
  82. const int k,
  83. Eigen::PlainObjectBase<DerivedW> & W);
  84. // Build the discrete k-harmonic operator (computing integrated quantities).
  85. // That is, if the k-harmonic PDE is Q x = 0, then this minimizes x' Q x
  86. //
  87. // Inputs:
  88. // L #V by #V discrete (integrated) Laplacian
  89. // M #V by #V mass matrix
  90. // k power of harmonic operation (1: harmonic, 2: biharmonic, etc)
  91. // Outputs:
  92. // Q #V by #V discrete (integrated) k-Laplacian
  93. template <
  94. typename DerivedL,
  95. typename DerivedM,
  96. typename DerivedQ>
  97. IGL_INLINE void harmonic(
  98. const Eigen::SparseMatrix<DerivedL> & L,
  99. const Eigen::SparseMatrix<DerivedM> & M,
  100. const int k,
  101. Eigen::SparseMatrix<DerivedQ> & Q);
  102. // Inputs:
  103. // V #V by dim vertex positions
  104. // F #F by simplex-size list of element indices
  105. // k power of harmonic operation (1: harmonic, 2: biharmonic, etc)
  106. // Outputs:
  107. // Q #V by #V discrete (integrated) k-Laplacian
  108. template <
  109. typename DerivedV,
  110. typename DerivedF,
  111. typename DerivedQ>
  112. IGL_INLINE void harmonic(
  113. const Eigen::MatrixBase<DerivedV> & V,
  114. const Eigen::MatrixBase<DerivedF> & F,
  115. const int k,
  116. Eigen::SparseMatrix<DerivedQ> & Q);
  117. };
  118. #ifndef IGL_STATIC_LIBRARY
  119. #include "harmonic.cpp"
  120. #endif
  121. #endif