barycentric_coordinates.h 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  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_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 in a tet
  15. //
  16. // Inputs:
  17. // P #P by 3 Query points in 3d
  18. // A #P by 3 Tet corners in 3d
  19. // B #P by 3 Tet corners in 3d
  20. // C #P by 3 Tet corners in 3d
  21. // D #P by 3 Tet corners in 3d
  22. // Outputs:
  23. // L #P by 4 list of barycentric coordinates
  24. //
  25. template <
  26. typename DerivedP,
  27. typename DerivedA,
  28. typename DerivedB,
  29. typename DerivedC,
  30. typename DerivedD,
  31. typename DerivedL>
  32. IGL_INLINE void barycentric_coordinates(
  33. const Eigen::PlainObjectBase<DerivedP> & P,
  34. const Eigen::PlainObjectBase<DerivedA> & A,
  35. const Eigen::PlainObjectBase<DerivedB> & B,
  36. const Eigen::PlainObjectBase<DerivedC> & C,
  37. const Eigen::PlainObjectBase<DerivedD> & D,
  38. Eigen::PlainObjectBase<DerivedL> & L);
  39. // Compute barycentric coordinates in a triangle
  40. //
  41. // Inputs:
  42. // P #P by dim Query points
  43. // A #P by dim Triangle corners
  44. // B #P by dim Triangle corners
  45. // C #P by dim Triangle corners
  46. // Outputs:
  47. // L #P by 3 list of barycentric coordinates
  48. //
  49. template <
  50. typename DerivedP,
  51. typename DerivedA,
  52. typename DerivedB,
  53. typename DerivedC,
  54. typename DerivedL>
  55. IGL_INLINE void barycentric_coordinates(
  56. const Eigen::MatrixBase<DerivedP> & P,
  57. const Eigen::MatrixBase<DerivedA> & A,
  58. const Eigen::MatrixBase<DerivedB> & B,
  59. const Eigen::MatrixBase<DerivedC> & C,
  60. Eigen::PlainObjectBase<DerivedL> & L);
  61. }
  62. #ifndef IGL_STATIC_LIBRARY
  63. # include "barycentric_coordinates.cpp"
  64. #endif
  65. #endif