cubic_is_flat.cpp 1.1 KB

1234567891011121314151617181920212223
  1. #include "cubic_is_flat.h"
  2. template <typename DerivedC>
  3. IGL_INLINE bool igl::cubic_is_flat(
  4. const Eigen::MatrixBase<DerivedC>& C,
  5. const typename DerivedC::Scalar squared_distance_bound)
  6. {
  7. using Scalar = typename DerivedC::Scalar;
  8. const auto u = (Scalar(3) * C.row(1) - Scalar(2) * C.row(0) - C.row(3)).array().square().eval();
  9. const auto v = (Scalar(3) * C.row(2) - Scalar(2) * C.row(3) - C.row(0)).array().square().eval();
  10. const auto max_uv = u.cwiseMax(v).eval();
  11. const Scalar tao = max_uv.sum();
  12. const Scalar tolerance = Scalar(16) * squared_distance_bound;
  13. return tao <= tolerance;
  14. }
  15. #ifdef IGL_STATIC_LIBRARY
  16. // Explicit template instantiation
  17. // generated by autoexplicit.sh
  18. template bool igl::cubic_is_flat<Eigen::Matrix<double, 4, 2, 1, 4, 2>>(Eigen::MatrixBase<Eigen::Matrix<double, 4, 2, 1, 4, 2>> const&, Eigen::Matrix<double, 4, 2, 1, 4, 2>::Scalar);
  19. // generated by autoexplicit.sh
  20. template bool igl::cubic_is_flat<Eigen::Matrix<double, 4, 2, 0, 4, 2>>(Eigen::MatrixBase<Eigen::Matrix<double, 4, 2, 0, 4, 2>> const&, Eigen::Matrix<double, 4, 2, 0, 4, 2>::Scalar);
  21. #endif