19 template <
typename Derived>
20 auto amips(
const Eigen::MatrixBase<Derived>& B)
22 using Scalar =
typename Derived::Scalar;
23 constexpr
static int Rows = Derived::RowsAtCompileTime;
24 constexpr
static int Cols = Derived::ColsAtCompileTime;
28 static_assert(Cols == 2);
29 static_assert(Rows == 2);
34 Eigen::Matrix<Scalar, Rows, 2> J;
37 auto Jdet = J.determinant();
38 if (
abs(Jdet) < std::numeric_limits<double>::denorm_min()) {
39 return static_cast<Scalar
>(std::numeric_limits<double>::infinity());
43 return (J * J.transpose()).trace() / Jdet;
48 template <
typename V0Type,
typename V1Type,
typename V2Type>
50 const Eigen::MatrixBase<V0Type>& v0,
51 const Eigen::MatrixBase<V1Type>& v1,
52 const Eigen::MatrixBase<V2Type>& v2)
54 using Scalar =
typename V0Type::Scalar;
55 constexpr
static int Rows = V0Type::RowsAtCompileTime;
56 constexpr
static int Cols0 = V0Type::ColsAtCompileTime;
57 constexpr
static int Cols1 = V1Type::ColsAtCompileTime;
58 constexpr
static int Cols2 = V1Type::ColsAtCompileTime;
62 static_assert(Cols0 == 1);
63 static_assert(Cols1 == 1);
64 static_assert(Cols2 == 1);
67 constexpr
static int Rows1 = V1Type::RowsAtCompileTime;
68 constexpr
static int Rows2 = V1Type::RowsAtCompileTime;
69 static_assert(Rows == Rows1);
70 static_assert(Rows == Rows2);
72 Eigen::Matrix<Scalar, 2, 2> Dm;
75 static_assert(Rows == 2 || Rows == 3);
77 if constexpr (Rows == 2) {
78 Dm.col(0) = (v1.template cast<Scalar>() - v0);
79 Dm.col(1) = (v2.template cast<Scalar>() - v0);
80 }
else if constexpr (Rows == 3) {
83 Eigen::Matrix<Scalar, Rows, 2> V;
84 V.col(0) = v1.template cast<Scalar>() - v0;
85 V.col(1) = v2.template cast<Scalar>() - v0;
88 Eigen::Matrix<Scalar, 3, 2> B = V;
94 auto e0norm = e0.norm();
100 auto e1norm = e1.norm();
105 Dm = (B.transpose() * V).eval();
113 void Tet_AMIPS_hessian(
const std::array<double, 12>& T, Eigen::Matrix3d& result_0);
const Eigen::Matrix2d amips_reference_to_barycentric
const Eigen::Matrix< double, 2, 3 > amips_target_triangle
void Tet_AMIPS_jacobian(const std::array< double, 12 > &T, Eigen::Vector3d &result_0)
auto amips(const Eigen::MatrixBase< Derived > &B)
double Tet_AMIPS_energy(const std::array< double, 12 > &T)
void Tet_AMIPS_hessian(const std::array< double, 12 > &T, Eigen::Matrix3d &result_0)
Rational abs(const Rational &r0)
Vector< double, 3 > Vector3d