per_face_normals.h 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637
  1. #ifndef IGL_PER_FACE_NORMALS_H
  2. #define IGL_PER_FACE_NORMALS_H
  3. #include "igl_inline.h"
  4. #include <Eigen/Core>
  5. namespace igl
  6. {
  7. // Compute face normals via vertex position list, face list
  8. // Inputs:
  9. // V #V by 3 eigen Matrix of mesh vertex 3D positions
  10. // F #F by 3 eigen Matrix of face (triangle) indices
  11. // Z 3 vector normal given to faces with degenerate normal.
  12. // Output:
  13. // N #F by 3 eigen Matrix of mesh face (triangle) 3D normals
  14. //
  15. // Example:
  16. // // Give degenerate faces (1/3,1/3,1/3)^0.5
  17. // per_face_normals(V,F,Vector3d(1,1,1).normalized(),N);
  18. template <typename DerivedV, typename DerivedF, typename DerivedZ, typename DerivedN>
  19. IGL_INLINE void per_face_normals(
  20. const Eigen::PlainObjectBase<DerivedV>& V,
  21. const Eigen::PlainObjectBase<DerivedF>& F,
  22. const Eigen::PlainObjectBase<DerivedZ> & Z,
  23. Eigen::PlainObjectBase<DerivedN> & N);
  24. // Wrapper with Z = (0,0,0). Note that this means that row norms will be zero
  25. // (i.e. not 1) for degenerate normals.
  26. template <typename DerivedV, typename DerivedF, typename DerivedN>
  27. IGL_INLINE void per_face_normals(
  28. const Eigen::PlainObjectBase<DerivedV>& V,
  29. const Eigen::PlainObjectBase<DerivedF>& F,
  30. Eigen::PlainObjectBase<DerivedN> & N);
  31. }
  32. #ifdef IGL_HEADER_ONLY
  33. # include "per_face_normals.cpp"
  34. #endif
  35. #endif