hausdorff.h 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  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. Even simpler, consider the
  24. // Hausdorff distance between the non-convex, block letter V polygon (with 7
  25. // vertices) in 2D and its convex hull. The Hausdorff distance is defined by
  26. // the midpoint in the middle of the segment across the concavity and some
  27. // non-vertex point _on the edge_ of the V.
  28. //
  29. // Inputs:
  30. // VA #VA by 3 list of vertex positions
  31. // FA #FA by 3 list of face indices into VA
  32. // VB #VB by 3 list of vertex positions
  33. // FB #FB by 3 list of face indices into VB
  34. // Outputs:
  35. // d hausdorff distance
  36. // //pair 2 by 3 list of "determiner points" so that pair(1,:) is from A
  37. // // and pair(2,:) is from B
  38. //
  39. template <
  40. typename DerivedVA,
  41. typename DerivedFA,
  42. typename DerivedVB,
  43. typename DerivedFB,
  44. typename Scalar>
  45. IGL_INLINE void hausdorff(
  46. const Eigen::PlainObjectBase<DerivedVA> & VA,
  47. const Eigen::PlainObjectBase<DerivedFA> & FA,
  48. const Eigen::PlainObjectBase<DerivedVB> & VB,
  49. const Eigen::PlainObjectBase<DerivedFB> & FB,
  50. Scalar & d);
  51. }
  52. #ifndef IGL_STATIC_LIBRARY
  53. # include "hausdorff.cpp"
  54. #endif
  55. #endif