point_mesh_squared_distance.h 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. // This file is part of libigl, a simple c++ geometry processing library.
  2. //
  3. // Copyright (C) 2014 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_POINT_MESH_SQUARED_DISTANCE_H
  9. #define IGL_POINT_MESH_SQUARED_DISTANCE_H
  10. #include "igl_inline.h"
  11. #include <Eigen/Core>
  12. #include <vector>
  13. namespace igl
  14. {
  15. // Compute distances from a set of points P to a triangle mesh (V,F)
  16. //
  17. // Inputs:
  18. // P #P by 3 list of query point positions
  19. // V #V by 3 list of vertex positions
  20. // F #F by 3 list of triangle indices
  21. // Outputs:
  22. // sqrD #P list of smallest squared distances
  23. // I #P list of facet indices corresponding to smallest distances
  24. // C #P by 3 list of closest points
  25. //
  26. // Known bugs: This only computes distances to triangles. So unreferenced
  27. // vertices and degenerate triangles (segments) are ignored.
  28. template <
  29. typename DerivedP,
  30. typename DerivedV,
  31. typename DerivedsqrD,
  32. typename DerivedI,
  33. typename DerivedC>
  34. IGL_INLINE void point_mesh_squared_distance(
  35. const Eigen::PlainObjectBase<DerivedP> & P,
  36. const Eigen::PlainObjectBase<DerivedV> & V,
  37. const Eigen::MatrixXi & Ele,
  38. Eigen::PlainObjectBase<DerivedsqrD> & sqrD,
  39. Eigen::PlainObjectBase<DerivedI> & I,
  40. Eigen::PlainObjectBase<DerivedC> & C);
  41. }
  42. #ifndef IGL_STATIC_LIBRARY
  43. # include "point_mesh_squared_distance.cpp"
  44. #endif
  45. #endif