hausdorff.h 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. // This file is part of libigl, a simple c++ geometry processing library.
  2. //
  3. // Copyright (C) 2015 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_HAUSDORFF_H
  9. #define IGL_HAUSDORFF_H
  10. #include "igl_inline.h"
  11. #include <Eigen/Dense>
  12. namespace igl
  13. {
  14. // HAUSDORFF compute the Hausdorff distance between mesh (VA,FA) and mesh
  15. // (VB,FB). This is the
  16. //
  17. // d(A,B) = max ( max min d(a,b) , max min d(b,a) )
  18. // a∈A b∈B b∈B a∈A
  19. //
  20. // Known issue: This is only computing max(min(va,B),min(vb,A)). This is
  21. // better than max(min(va,Vb),min(vb,Va)). This (at least) is missing
  22. // "edge-edge" cases like the distance between the two different
  23. // triangulations of a non-planar quad in 3D.
  24. //
  25. // Inputs:
  26. // VA #VA by 3 list of vertex positions
  27. // FA #FA by 3 list of face indices into VA
  28. // VB #VB by 3 list of vertex positions
  29. // FB #FB by 3 list of face indices into VB
  30. // Outputs:
  31. // d hausdorff distance
  32. // //pair 2 by 3 list of "determiner points" so that pair(1,:) is from A
  33. // // and pair(2,:) is from B
  34. //
  35. template <
  36. typename DerivedVA,
  37. typename DerivedFA,
  38. typename DerivedVB,
  39. typename DerivedFB,
  40. typename Scalar>
  41. IGL_INLINE void hausdorff(
  42. const Eigen::PlainObjectBase<DerivedVA> & VA,
  43. const Eigen::PlainObjectBase<DerivedFA> & FA,
  44. const Eigen::PlainObjectBase<DerivedVB> & VB,
  45. const Eigen::PlainObjectBase<DerivedFB> & FB,
  46. Scalar & d);
  47. }
  48. #ifndef IGL_STATIC_LIBRARY
  49. # include "hausdorff.cpp"
  50. #endif
  51. #endif