cotmatrix.h 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. // This file is part of libigl, a simple c++ geometry processing library.
  2. //
  3. // Copyright (C) 2014 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. #include <Eigen/Dense>
  12. #include <Eigen/Sparse>
  13. // History:
  14. // Used const references rather than copying the entire mesh
  15. // Alec 9 October 2011
  16. // removed cotan (uniform weights) optional parameter it was building a buggy
  17. // half of the uniform laplacian, please see adjacency_matrix istead
  18. // Alec 9 October 2011
  19. namespace igl
  20. {
  21. // Constructs the cotangent stiffness matrix (discrete laplacian) for a given
  22. // mesh (V,F).
  23. //
  24. // Templates:
  25. // DerivedV derived type of eigen matrix for V (e.g. derived from
  26. // MatrixXd)
  27. // DerivedF derived type of eigen matrix for F (e.g. derived from
  28. // MatrixXi)
  29. // Scalar scalar type for eigen sparse matrix (e.g. double)
  30. // Inputs:
  31. // V #V by dim list of mesh vertex positions
  32. // F #F by simplex_size list of mesh faces (must be triangles)
  33. // Outputs:
  34. // L #V by #V cotangent matrix, each row i corresponding to V(i,:)
  35. //
  36. // See also: adjacency_matrix
  37. //
  38. // Note: This Laplacian uses the convention that diagonal entries are
  39. // **minus** the sum of off-diagonal entries. The diagonal entries are
  40. // therefore in general negative and the matrix is **negative** semi-definite
  41. // (immediately, -L is **positive** semi-definite)
  42. //
  43. // Known bugs: off by 1e-16 on regular grid. I think its a problem of
  44. // arithmetic order in cotmatrix_entries.h: C(i,e) = (arithmetic)/dblA/4
  45. template <typename DerivedV, typename DerivedF, typename Scalar>
  46. IGL_INLINE void cotmatrix(
  47. const Eigen::PlainObjectBase<DerivedV> & V,
  48. const Eigen::PlainObjectBase<DerivedF> & F,
  49. Eigen::SparseMatrix<Scalar>& L);
  50. }
  51. #ifndef IGL_STATIC_LIBRARY
  52. # include "cotmatrix.cpp"
  53. #endif
  54. #endif