barycentric_coordinates.h 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  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 2 Query points in 2d
  43. // A #P by 2 Triangle corners in 2d
  44. // B #P by 2 Triangle corners in 2d
  45. // C #P by 2 Triangle corners in 2d
  46. // Outputs:
  47. // L #P by e list of barycentric coordinates
  48. //
  49. // Known bugs: this code is not tested (and probably will not work) for
  50. // triangles and queries in 3D even if the query lives in/on the triangle.
  51. template <
  52. typename DerivedP,
  53. typename DerivedA,
  54. typename DerivedB,
  55. typename DerivedC,
  56. typename DerivedL>
  57. IGL_INLINE void barycentric_coordinates(
  58. const Eigen::PlainObjectBase<DerivedP> & P,
  59. const Eigen::PlainObjectBase<DerivedA> & A,
  60. const Eigen::PlainObjectBase<DerivedB> & B,
  61. const Eigen::PlainObjectBase<DerivedC> & C,
  62. Eigen::PlainObjectBase<DerivedL> & L);
  63. }
  64. #ifndef IGL_STATIC_LIBRARY
  65. # include "barycentric_coordinates.cpp"
  66. #endif
  67. #endif