arap_linear_block.h 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  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_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. // ARAP_LINEAR_BLOCK 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. // K * R = [Kx Z ... Ky Z ...
  20. // Z Kx ... Z Ky ...
  21. // ... ]
  22. // These blocks are also used to build the "covariance scatter matrices".
  23. // Here we want to build a scatter matrix that multiplies against positions
  24. // (treated as known) producing covariance matrices to fit each rotation.
  25. // Notice that in the case of the RHS of the poisson solve the rotations are
  26. // known and the positions unknown, and vice versa for rotation fitting.
  27. // These linear block just relate the rotations to the positions, linearly in
  28. // each.
  29. //
  30. // Templates:
  31. // MatV vertex position matrix, e.g. Eigen::MatrixXd
  32. // MatF face index matrix, e.g. Eigen::MatrixXd
  33. // Scalar e.g. double
  34. // Inputs:
  35. // V #V by dim list of initial domain positions
  36. // F #F by #simplex size list of triangle indices into V
  37. // d coordinate of linear constructor to build
  38. // energy ARAPEnergyType enum value defining which energy is being used.
  39. // See ARAPEnergyType.h for valid options and explanations.
  40. // Outputs:
  41. // Kd #V by #V/#F block of the linear constructor matrix corresponding to
  42. // coordinate d
  43. //
  44. template <typename MatV, typename MatF, typename Scalar>
  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. Eigen::SparseMatrix<Scalar> & Kd);
  51. // Helper functions for each energy type
  52. template <typename MatV, typename MatF, typename Scalar>
  53. IGL_INLINE void arap_linear_block_spokes(
  54. const MatV & V,
  55. const MatF & F,
  56. const int d,
  57. Eigen::SparseMatrix<Scalar> & Kd);
  58. template <typename MatV, typename MatF, typename Scalar>
  59. IGL_INLINE void arap_linear_block_spokes_and_rims(
  60. const MatV & V,
  61. const MatF & F,
  62. const int d,
  63. Eigen::SparseMatrix<Scalar> & Kd);
  64. template <typename MatV, typename MatF, typename Scalar>
  65. IGL_INLINE void arap_linear_block_elements(
  66. const MatV & V,
  67. const MatF & F,
  68. const int d,
  69. Eigen::SparseMatrix<Scalar> & Kd);
  70. }
  71. #ifndef IGL_STATIC_LIBRARY
  72. # include "arap_linear_block.cpp"
  73. #endif
  74. #endif