project_to_line_segment.h 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. // This file is part of libigl, a simple c++ geometry processing library.
  2. //
  3. // Copyright (C) 2013 Alec Jacobson <[email protected]>
  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 points onto vectors, that is find the parameter
  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. /// @param[in] P #P by dim list of points to be projected
  20. /// @param[in] S size dim start position of line vector
  21. /// @param[in] D size dim destination position of line vector
  22. /// @param[out] T #P by 1 list of parameters
  23. /// @param[out] sqrD #P by 1 list of squared distances
  24. template <
  25. typename DerivedP,
  26. typename DerivedS,
  27. typename DerivedD,
  28. typename Derivedt,
  29. typename DerivedsqrD>
  30. IGL_INLINE void project_to_line_segment(
  31. const Eigen::MatrixBase<DerivedP> & P,
  32. const Eigen::MatrixBase<DerivedS> & S,
  33. const Eigen::MatrixBase<DerivedD> & D,
  34. Eigen::PlainObjectBase<Derivedt> & t,
  35. Eigen::PlainObjectBase<DerivedsqrD> & sqrD);
  36. }
  37. #ifndef IGL_STATIC_LIBRARY
  38. # include "project_to_line_segment.cpp"
  39. #endif
  40. #endif