project_to_line_segment.h 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. // This file is part of libigl, a simple c++ geometry processing library.
  2. //
  3. // Copyright (C) 2013 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_PROJECT_TO_LINE_SEGMENT_H
  9. #define IGL_PROJECT_TO_LINE_SEGMENT_H
  10. #include "igl_inline.h"
  11. #include <Eigen/Core>
  12. namespace igl
  13. {
  14. // PROJECT_TO_LINE_SEGMENT project points onto vectors, that is find the paramter
  15. // t for a point p such that proj_p = (y-x).*t, additionally compute the
  16. // squared distance from p to the line of the vector, such that
  17. // |p - proj_p|² = sqr_d
  18. //
  19. // [T,sqrD] = project_to_line_segment(P,S,D)
  20. //
  21. // Inputs:
  22. // P #P by dim list of points to be projected
  23. // S size dim start position of line vector
  24. // D size dim destination position of line vector
  25. // Outputs:
  26. // T #P by 1 list of parameters
  27. // sqrD #P by 1 list of squared distances
  28. //
  29. //
  30. template <
  31. typename DerivedP,
  32. typename DerivedS,
  33. typename DerivedD,
  34. typename Derivedt,
  35. typename DerivedsqrD>
  36. IGL_INLINE void project_to_line_segment(
  37. const Eigen::MatrixBase<DerivedP> & P,
  38. const Eigen::MatrixBase<DerivedS> & S,
  39. const Eigen::MatrixBase<DerivedD> & D,
  40. Eigen::PlainObjectBase<Derivedt> & t,
  41. Eigen::PlainObjectBase<DerivedsqrD> & sqrD);
  42. }
  43. #ifndef IGL_STATIC_LIBRARY
  44. # include "project_to_line_segment.cpp"
  45. #endif
  46. #endif