barycentric_coordinates.h 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. // This file is part of libigl, a simple c++ geometry processing library.
  2. //
  3. // Copyright (C) 2014 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_BARYCENTRIC_COORDINATES_H
  9. #define IGL_BARYCENTRIC_COORDINATES_H
  10. #include "igl_inline.h"
  11. #include <Eigen/Core>
  12. namespace igl
  13. {
  14. /// Compute barycentric coordinates of each point in a corresponding tetrahedron.
  15. ///
  16. /// @param[in] P #P by 3 Query points in 3d
  17. /// @param[in] A #P by 3 Tet corners in 3d
  18. /// @param[in] B #P by 3 Tet corners in 3d
  19. /// @param[in] C #P by 3 Tet corners in 3d
  20. /// @param[in] D #P by 3 Tet corners in 3d
  21. /// @param[out] L #P by 4 list of barycentric coordinates
  22. ///
  23. template <
  24. typename DerivedP,
  25. typename DerivedA,
  26. typename DerivedB,
  27. typename DerivedC,
  28. typename DerivedD,
  29. typename DerivedL>
  30. IGL_INLINE void barycentric_coordinates(
  31. const Eigen::MatrixBase<DerivedP> & P,
  32. const Eigen::MatrixBase<DerivedA> & A,
  33. const Eigen::MatrixBase<DerivedB> & B,
  34. const Eigen::MatrixBase<DerivedC> & C,
  35. const Eigen::MatrixBase<DerivedD> & D,
  36. Eigen::PlainObjectBase<DerivedL> & L);
  37. /// Compute barycentric coordinates in a triangle
  38. ///
  39. /// @param[in] P #P by dim Query points
  40. /// @param[in] A #P by dim Triangle corners
  41. /// @param[in] B #P by dim Triangle corners
  42. /// @param[in] C #P by dim Triangle corners
  43. /// @param[out] L #P by 3 list of barycentric coordinates
  44. ///
  45. template <
  46. typename DerivedP,
  47. typename DerivedA,
  48. typename DerivedB,
  49. typename DerivedC,
  50. typename DerivedL>
  51. IGL_INLINE void barycentric_coordinates(
  52. const Eigen::MatrixBase<DerivedP> & P,
  53. const Eigen::MatrixBase<DerivedA> & A,
  54. const Eigen::MatrixBase<DerivedB> & B,
  55. const Eigen::MatrixBase<DerivedC> & C,
  56. Eigen::PlainObjectBase<DerivedL> & L);
  57. }
  58. #ifndef IGL_STATIC_LIBRARY
  59. # include "barycentric_coordinates.cpp"
  60. #endif
  61. #endif