cotmatrix.h 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  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_COTMATRIX_H
  9. #define IGL_COTMATRIX_H
  10. #include "igl_inline.h"
  11. #define EIGEN_YES_I_KNOW_SPARSE_MODULE_IS_NOT_STABLE_YET
  12. #include <Eigen/Dense>
  13. #include <Eigen/Sparse>
  14. // History:
  15. // Used const references rather than copying the entire mesh
  16. // Alec 9 October 2011
  17. // removed cotan (uniform weights) optional parameter it was building a buggy
  18. // half of the uniform laplacian, please see adjacency_matrix istead
  19. // Alec 9 October 2011
  20. namespace igl
  21. {
  22. // Constructs the cotangent stiffness matrix (discrete laplacian) for a given
  23. // mesh (V,F).
  24. //
  25. // Templates:
  26. // DerivedV derived type of eigen matrix for V (e.g. derived from
  27. // MatrixXd)
  28. // DerivedF derived type of eigen matrix for F (e.g. derived from
  29. // MatrixXi)
  30. // Scalar scalar type for eigen sparse matrix (e.g. double)
  31. // Inputs:
  32. // V #V by dim list of mesh vertex positions
  33. // F #F by simplex_size list of mesh faces (must be triangles)
  34. // Outputs:
  35. // L #V by #V cotangent matrix, each row i corresponding to V(i,:)
  36. //
  37. // See also: adjacency_matrix
  38. //
  39. // Known bugs: off by 1e-16 on regular grid. I think its a problem of
  40. // arithmetic order in cotangent.h: C(i,e) = (arithmetic)/dblA/4
  41. template <typename DerivedV, typename DerivedF, typename Scalar>
  42. IGL_INLINE void cotmatrix(
  43. const Eigen::MatrixBase<DerivedV> & V,
  44. const Eigen::MatrixBase<DerivedF> & F,
  45. Eigen::SparseMatrix<Scalar>& L);
  46. }
  47. #ifdef IGL_HEADER_ONLY
  48. # include "cotmatrix.cpp"
  49. #endif
  50. #endif