cotmatrix.h 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  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. #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. // Known bugs: off by 1e-16 on regular grid. I think its a problem of
  39. // arithmetic order in cotmatrix_entries.h: C(i,e) = (arithmetic)/dblA/4
  40. template <typename DerivedV, typename DerivedF, typename Scalar>
  41. IGL_INLINE void cotmatrix(
  42. const Eigen::PlainObjectBase<DerivedV> & V,
  43. const Eigen::PlainObjectBase<DerivedF> & F,
  44. Eigen::SparseMatrix<Scalar>& L);
  45. }
  46. #ifndef IGL_STATIC_LIBRARY
  47. # include "cotmatrix.cpp"
  48. #endif
  49. #endif