20auto 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;
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();