cubic.cpp 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. #include "cubic.h"
  2. template
  3. <
  4. typename DerivedC,
  5. typename DerivedP>
  6. IGL_INLINE void igl::cubic(
  7. const Eigen::MatrixBase<DerivedC>& C,
  8. const typename DerivedP::Scalar & t,
  9. Eigen::PlainObjectBase<DerivedP>& P)
  10. {
  11. // static assert that C has 4 rows or Dynamic
  12. static_assert(
  13. DerivedC::RowsAtCompileTime == 4 ||
  14. DerivedC::RowsAtCompileTime == Eigen::Dynamic,
  15. "C must have 4 rows.");
  16. // runtime assert that C has 4 rows
  17. assert(C.rows() == 4 && "C must have 4 rows.");
  18. using Scalar = typename DerivedP::Scalar;
  19. // Evaluate cubic Bezier at parameter t
  20. P =
  21. (Scalar(1) - t) * (Scalar(1) - t) * (Scalar(1) - t) * C.row(0)
  22. + Scalar(3) * (Scalar(1) - t) * (Scalar(1) - t) * t * C.row(1)
  23. + Scalar(3) * (Scalar(1) - t) * t * t * C.row(2)
  24. + t * t * t * C.row(3);
  25. }
  26. #ifdef IGL_STATIC_LIBRARY
  27. // Explicit template instantiation
  28. // generated by autoexplicit.sh
  29. template void igl::cubic<Eigen::Matrix<double, -1, -1, 0, -1, -1>, Eigen::Matrix<double, 1, -1, 1, 1, -1>>(Eigen::MatrixBase<Eigen::Matrix<double, -1, -1, 0, -1, -1>> const&, Eigen::Matrix<double, 1, -1, 1, 1, -1>::Scalar const&, Eigen::PlainObjectBase<Eigen::Matrix<double, 1, -1, 1, 1, -1>>&);
  30. // generated by autoexplicit.sh
  31. template void igl::cubic<Eigen::Matrix<double, 4, -1, 0, 4, -1>, Eigen::Matrix<double, 1, -1, 1, 1, -1>>(Eigen::MatrixBase<Eigen::Matrix<double, 4, -1, 0, 4, -1>> const&, Eigen::Matrix<double, 1, -1, 1, 1, -1>::Scalar const&, Eigen::PlainObjectBase<Eigen::Matrix<double, 1, -1, 1, 1, -1>>&);
  32. // generated by autoexplicit.sh
  33. template void igl::cubic<Eigen::Block<Eigen::Matrix<double, -1, -1, 0, -1, -1> const, -1, 1, true>, Eigen::Matrix<double, 1, 1, 0, 1, 1>>(Eigen::MatrixBase<Eigen::Block<Eigen::Matrix<double, -1, -1, 0, -1, -1> const, -1, 1, true>> const&, Eigen::Matrix<double, 1, 1, 0, 1, 1>::Scalar const&, Eigen::PlainObjectBase<Eigen::Matrix<double, 1, 1, 0, 1, 1>>&);
  34. // generated by autoexplicit.sh
  35. template void igl::cubic<Eigen::IndexedView<Eigen::Matrix<double, -1, -1, 0, -1, -1>, Eigen::Block<Eigen::Matrix<int, -1, -1, 0, -1, -1>, 1, -1, false>, Eigen::internal::AllRange<-1>>, Eigen::Matrix<double, 1, -1, 1, 1, -1>>(Eigen::MatrixBase<Eigen::IndexedView<Eigen::Matrix<double, -1, -1, 0, -1, -1>, Eigen::Block<Eigen::Matrix<int, -1, -1, 0, -1, -1>, 1, -1, false>, Eigen::internal::AllRange<-1>>> const&, Eigen::Matrix<double, 1, -1, 1, 1, -1>::Scalar const&, Eigen::PlainObjectBase<Eigen::Matrix<double, 1, -1, 1, 1, -1>>&);
  36. #endif