per_vertex_normals.h 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  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_PER_VERTEX_NORMALS_H
  9. #define IGL_PER_VERTEX_NORMALS_H
  10. #include "igl_inline.h"
  11. #include <Eigen/Core>
  12. // Note: So for this only computes normals per vertex as uniformly weighted
  13. // averages of incident triangle normals. It would be nice to support more or
  14. // all of the methods here:
  15. // "A comparison of algorithms for vertex normal computation"
  16. namespace igl
  17. {
  18. // Compute vertex normals via vertex position list, face list
  19. // Inputs:
  20. // V #V by 3 eigen Matrix of mesh vertex 3D positions
  21. // F #F by 3 eigne Matrix of face (triangle) indices
  22. // Output:
  23. // N #V by 3 eigen Matrix of mesh vertex 3D normals
  24. template <typename DerivedV, typename DerivedF>
  25. IGL_INLINE void per_vertex_normals(
  26. const Eigen::PlainObjectBase<DerivedV>& V,
  27. const Eigen::PlainObjectBase<DerivedF>& F,
  28. Eigen::PlainObjectBase<DerivedV> & N);
  29. template <typename DerivedV, typename DerivedF>
  30. IGL_INLINE void per_vertex_normals(
  31. const Eigen::PlainObjectBase<DerivedV>& V,
  32. const Eigen::PlainObjectBase<DerivedF>& F,
  33. const Eigen::PlainObjectBase<DerivedV>& FN,
  34. Eigen::PlainObjectBase<DerivedV> & N);
  35. }
  36. #ifdef IGL_HEADER_ONLY
  37. # include "per_vertex_normals.cpp"
  38. #endif
  39. #endif