arap_linear_block.h 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113
  1. // This file is part of libigl, a simple c++ geometry processing library.
  2. //
  3. // Copyright (C) 2013 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_ARAP_LINEAR_BLOCK_H
  9. #define IGL_ARAP_LINEAR_BLOCK_H
  10. #include "igl_inline.h"
  11. #include <Eigen/Sparse>
  12. #include <igl/ARAPEnergyType.h>
  13. namespace igl
  14. {
  15. /// Constructs a block of the matrix which constructs the
  16. /// linear terms of a given arap energy. When treating rotations as knowns
  17. /// (arranged in a column) then this constructs Kd of K such that the linear
  18. /// portion of the energy is as a column:
  19. ///
  20. /// K * R = [Kx Z ... Ky Z ...
  21. /// Z Kx ... Z Ky ...
  22. /// ... ]
  23. ///
  24. /// These blocks are also used to build the "covariance scatter matrices".
  25. /// Here we want to build a scatter matrix that multiplies against positions
  26. /// (treated as known) producing covariance matrices to fit each rotation.
  27. /// Notice that in the case of the RHS of the poisson solve the rotations are
  28. /// known and the positions unknown, and vice versa for rotation fitting.
  29. /// These linear block just relate the rotations to the positions, linearly in
  30. /// each.
  31. ///
  32. /// @tparam MatV vertex position matrix, e.g. Eigen::MatrixXd
  33. /// @tparam MatF face index matrix, e.g. Eigen::MatrixXd
  34. /// @tparam Scalar e.g. double
  35. /// @param[in] V #V by dim list of initial domain positions
  36. /// @param[in] F #F by #simplex size list of triangle indices into V
  37. /// @param[in] d coordinate of linear constructor to build
  38. /// @param[in] energy ARAPEnergyType enum value defining which energy is being used.
  39. /// See ARAPEnergyType.h for valid options and explanations.
  40. /// @param[out] Kd #V by #V/#F block of the linear constructor matrix
  41. /// corresponding to coordinate d
  42. ///
  43. /// \see ARAPEnergyType
  44. template <typename MatV, typename MatF, typename MatK>
  45. IGL_INLINE void arap_linear_block(
  46. const MatV & V,
  47. const MatF & F,
  48. const int d,
  49. const igl::ARAPEnergyType energy,
  50. MatK & Kd);
  51. /// Constructs a block of the matrix which constructs the linear terms for
  52. /// spokes energy.
  53. ///
  54. /// @tparam MatV vertex position matrix, e.g. Eigen::MatrixXd
  55. /// @tparam MatF face index matrix, e.g. Eigen::MatrixXd
  56. /// @tparam Scalar e.g. double
  57. /// @param[in] V #V by dim list of initial domain positions
  58. /// @param[in] F #F by #simplex size list of triangle indices into V
  59. /// @param[in] d coordinate of linear constructor to build (0 index)
  60. /// See ARAPEnergyType.h for valid options and explanations.
  61. /// @param[out] Kd #V by #V block of the linear constructor matrix
  62. /// corresponding to coordinate d
  63. template <typename MatV, typename MatF, typename MatK>
  64. IGL_INLINE void arap_linear_block_spokes(
  65. const MatV & V,
  66. const MatF & F,
  67. const int d,
  68. MatK & Kd);
  69. /// Constructs a block of the matrix which constructs the linear terms for
  70. /// spokes and rims energy.
  71. ///
  72. /// @tparam MatV vertex position matrix, e.g. Eigen::MatrixXd
  73. /// @tparam MatF face index matrix, e.g. Eigen::MatrixXd
  74. /// @tparam Scalar e.g. double
  75. /// @param[in] V #V by dim list of initial domain positions
  76. /// @param[in] F #F by #simplex size list of triangle indices into V
  77. /// @param[in] d coordinate of linear constructor to build (0 index)
  78. /// See ARAPEnergyType.h for valid options and explanations.
  79. /// @param[out] Kd #V by #V block of the linear constructor matrix
  80. /// corresponding to coordinate d
  81. template <typename MatV, typename MatF, typename MatK>
  82. IGL_INLINE void arap_linear_block_spokes_and_rims(
  83. const MatV & V,
  84. const MatF & F,
  85. const int d,
  86. MatK & Kd);
  87. /// Constructs a block of the matrix which constructs the linear terms for
  88. /// per element energy.
  89. ///
  90. /// @tparam MatV vertex position matrix, e.g. Eigen::MatrixXd
  91. /// @tparam MatF face index matrix, e.g. Eigen::MatrixXd
  92. /// @tparam Scalar e.g. double
  93. /// @param[in] V #V by dim list of initial domain positions
  94. /// @param[in] F #F by #simplex size list of triangle indices into V
  95. /// @param[in] d coordinate of linear constructor to build (0 index)
  96. /// See ARAPEnergyType.h for valid options and explanations.
  97. /// @param[out] Kd #V by #F block of the linear constructor matrix
  98. /// corresponding to coordinate d
  99. template <typename MatV, typename MatF, typename MatK>
  100. IGL_INLINE void arap_linear_block_elements(
  101. const MatV & V,
  102. const MatF & F,
  103. const int d,
  104. MatK & Kd);
  105. }
  106. #ifndef IGL_STATIC_LIBRARY
  107. # include "arap_linear_block.cpp"
  108. #endif
  109. #endif