BSplineGeodesic.h 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. // David Eberly, Geometric Tools, Redmond WA 98052
  2. // Copyright (c) 1998-2020
  3. // Distributed under the Boost Software License, Version 1.0.
  4. // https://www.boost.org/LICENSE_1_0.txt
  5. // https://www.geometrictools.com/License/Boost/LICENSE_1_0.txt
  6. // Version: 4.0.2019.08.13
  7. #pragma once
  8. #include <Mathematics/RiemannianGeodesic.h>
  9. #include <Mathematics/BSplineSurface.h>
  10. namespace WwiseGTE
  11. {
  12. template <typename Real>
  13. class BSplineGeodesic : public RiemannianGeodesic<Real>
  14. {
  15. public:
  16. BSplineGeodesic(BSplineSurface<3, Real> const& spline)
  17. :
  18. RiemannianGeodesic<Real>(2),
  19. mSpline(&spline)
  20. {
  21. }
  22. virtual ~BSplineGeodesic()
  23. {
  24. }
  25. private:
  26. virtual void ComputeMetric(const GVector<Real>& point) override
  27. {
  28. mSpline->Evaluate(point[0], point[1], 2, mJet);
  29. Vector<3, Real> const& der0 = mJet[1];
  30. Vector<3, Real> const& der1 = mJet[2];
  31. this->mMetric(0, 0) = Dot(der0, der0);
  32. this->mMetric(0, 1) = Dot(der0, der1);
  33. this->mMetric(1, 0) = this->mMetric(0, 1);
  34. this->mMetric(1, 1) = Dot(der1, der1);
  35. }
  36. virtual void ComputeChristoffel1(const GVector<Real>&) override
  37. {
  38. Vector<3, Real> const& der0 = mJet[1];
  39. Vector<3, Real> const& der1 = mJet[2];
  40. Vector<3, Real> const& der00 = mJet[3];
  41. Vector<3, Real> const& der01 = mJet[4];
  42. Vector<3, Real> const& der11 = mJet[5];
  43. this->mChristoffel1[0](0, 0) = Dot(der00, der0);
  44. this->mChristoffel1[0](0, 1) = Dot(der01, der0);
  45. this->mChristoffel1[0](1, 0) = this->mChristoffel1[0](0, 1);
  46. this->mChristoffel1[0](1, 1) = Dot(der11, der0);
  47. this->mChristoffel1[1](0, 0) = Dot(der00, der1);
  48. this->mChristoffel1[1](0, 1) = Dot(der01, der1);
  49. this->mChristoffel1[1](1, 0) = this->mChristoffel1[1](0, 1);
  50. this->mChristoffel1[1](1, 1) = Dot(der11, der1);
  51. }
  52. BSplineSurface<3, Real> const* mSpline;
  53. // We are guaranteed that RiemannianGeodesic calls ComputeMetric
  54. // before ComputeChristoffel1. Thus, we can compute the B-spline
  55. // first- and second-order derivatives in ComputeMetric and cache
  56. // the results for use in ComputeChristoffel1.
  57. Vector<3, Real> mJet[6];
  58. };
  59. }