round_cone_signed_distance.h 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. // This file is part of libigl, a simple c++ geometry processing library.
  2. //
  3. // Copyright (C) 2025 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_ROUND_CONE_SIGNED_DISTANCE_H
  9. #define IGL_ROUND_CONE_SIGNED_DISTANCE_H
  10. #include "igl_inline.h"
  11. #include <Eigen/Core>
  12. namespace igl
  13. {
  14. /// Compute signed distance to a round cone (sphere-mesh capsule).
  15. ///
  16. /// @param[in] p 3-vector query point
  17. /// @param[in] a 3-vector position of the first vertex
  18. /// @param[in] b 3-vector position of the second vertex
  19. /// @param[in] r1 radius at vertex a
  20. /// @param[in] r2 radius at vertex b
  21. /// @return signed distance to the round cone
  22. template <
  23. typename Derivedp,
  24. typename Deriveda,
  25. typename Derivedb>
  26. IGL_INLINE typename Derivedp::Scalar round_cone_signed_distance(
  27. const Eigen::MatrixBase<Derivedp> & p,
  28. const Eigen::MatrixBase<Deriveda> & a,
  29. const Eigen::MatrixBase<Derivedb> & b,
  30. const typename Derivedp::Scalar & r1,
  31. const typename Derivedp::Scalar & r2);
  32. /// Compute signed distance to a round cone (sphere-mesh capsule) with
  33. /// pre-computed values that are independent of the query point.
  34. ///
  35. /// @param[in] p 3-vector query point
  36. /// @param[in] a 3-vector position of the first vertex
  37. /// @param[in] r1 radius at vertex a
  38. /// @param[in] r2 radius at vertex b
  39. /// @param[in] ba 3-vector direction from a to b
  40. /// @param[in] l2 squared length of ba
  41. /// @param[in] rr r1 - r2
  42. /// @param[in] a2 l2 - rr*rr
  43. /// @param[in] il2 1/l2
  44. /// @return signed distance to the round cone
  45. template <
  46. typename Derivedp,
  47. typename Deriveda,
  48. typename Derivedba>
  49. IGL_INLINE typename Derivedp::Scalar round_cone_signed_distance(
  50. const Eigen::MatrixBase<Derivedp> & p,
  51. const Eigen::MatrixBase<Deriveda> & a,
  52. const typename Derivedp::Scalar & r1,
  53. const typename Derivedp::Scalar & r2,
  54. const Eigen::MatrixBase<Derivedba> & ba,
  55. const typename Derivedp::Scalar & l2,
  56. const typename Derivedp::Scalar & rr,
  57. const typename Derivedp::Scalar & a2,
  58. const typename Derivedp::Scalar & il2);
  59. }
  60. #ifndef IGL_STATIC_LIBRARY
  61. # include "round_cone_signed_distance.cpp"
  62. #endif
  63. #endif