25 #ifndef NIHU_PLANE_ELEMENT_HELPER_HPP_INCLUDED
26 #define NIHU_PLANE_ELEMENT_HELPER_HPP_INCLUDED
39 template <
class elem_t>
43 typename elem_t::scalar_t r[],
44 typename elem_t::scalar_t theta[],
45 typename elem_t::scalar_t alpha[])
48 enum{ N = elem_t::domain_t::num_corners };
50 auto const &C_old = elem.get_coords();
53 for (
unsigned i = 0; i < N; ++i)
55 R.col(i) = C_old.col(i) - x0;
56 r[i] = R.col(i).norm();
58 C.col(i) = C_old.col(i) - C_old.col((i+1) % N);
59 C.col(i) /=
C.col(i).norm();
62 for (
unsigned i = 0; i < N; ++i)
64 double cs = R.col(i).dot(R.col((i+1) % N));
68 theta[i] = std::acos(cs);
69 alpha[i] = std::acos(R.col(i).dot(
C.col(i)));
73 template <
class matrixDerived,
class vectorDerived>
74 void plane_elem_helper_mid(
75 Eigen::DenseBase<matrixDerived>
const &coords,
76 Eigen::DenseBase<vectorDerived>
const &x0,
77 double ref_distance[],
83 unsigned const N = coords.cols();
84 for (
unsigned n = 0; n < N; ++n)
86 Eigen::Matrix<double, 2, 1> c1 = coords.topRows(2).col(n);
87 Eigen::Matrix<double, 2, 1> c2 = coords.topRows(2).col((n + 1) % N);
89 Eigen::Matrix<double, 2, 1> l = (c2 - c1).normalized();
91 Eigen::Matrix<double, 2, 1> d1 = c1 - x0.topRows(2);
92 Eigen::Matrix<double, 2, 1> d0 = d1 - l * d1.dot(l);
94 theta_lim[n] = std::atan2(d1(1), d1(0));
95 theta0[n] = std::atan2(d0(1), d0(0));
96 ref_distance[n] = d0.norm();
112 Eigen::DenseBase<V>
const &v1_in,
113 Eigen::DenseBase<V>
const &v2_in)
116 Eigen::Matrix<double, 3, 1> v1 = v1_in;
117 Eigen::Matrix<double, 3, 1> v2 = v2_in;
119 Eigen::Matrix<double, 3, 3> T;
120 T.col(0) = v1.normalized();
121 T.col(2) = v1.cross(v2).normalized();
122 T.col(1) = T.col(2).cross(T.col(0)).normalized();