point_simplex_squared_distance.h 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. // This file is part of libigl, a simple c++ geometry processing library.
  2. //
  3. // Copyright (C) 2016 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_SIMPLEX_SQUARED_DISTANCE_H
  9. #define IGL_POINT_SIMPLEX_SQUARED_DISTANCE_H
  10. #include "igl_inline.h"
  11. #include <Eigen/Core>
  12. namespace igl
  13. {
  14. // Determine squared distance from a point to linear simplex.
  15. //
  16. // Inputs:
  17. // p d-long query point
  18. // V #V by d list of vertices
  19. // Ele #Ele by ss<=d+1 list of simplex indices into V
  20. // i index into Ele of simplex
  21. // Outputs:
  22. // sqr_d squared distance of Ele(i) to p
  23. // c closest point on Ele(i)
  24. //
  25. template <
  26. int DIM,
  27. typename Derivedp,
  28. typename DerivedV,
  29. typename DerivedEle,
  30. typename Derivedsqr_d,
  31. typename Derivedc>
  32. IGL_INLINE void point_simplex_squared_distance(
  33. const Eigen::MatrixBase<Derivedp> & p,
  34. const Eigen::MatrixBase<DerivedV> & V,
  35. const Eigen::MatrixBase<DerivedEle> & Ele,
  36. const typename DerivedEle::Index i,
  37. Derivedsqr_d & sqr_d,
  38. Eigen::PlainObjectBase<Derivedc> & c);
  39. }
  40. #ifndef IGL_STATIC_LIBRARY
  41. # include "point_simplex_squared_distance.cpp"
  42. #endif
  43. #endif