53 const Eigen::MatrixBase<Derived>& x,
const Eigen::MatrixBase<Derived>& y,
60 const Eigen::MatrixBase<Derived2>& _u,
61 const Eigen::MatrixBase<Derived3>& _v) {
62 typedef typename Derived1::Scalar T;
64 Eigen::MatrixBase<Derived1>& w =
const_cast<Eigen::MatrixBase<Derived1>&
>(_w);
65 Eigen::MatrixBase<Derived2>& u =
const_cast<Eigen::MatrixBase<Derived2>&
>(_u);
66 Eigen::MatrixBase<Derived3>& v =
const_cast<Eigen::MatrixBase<Derived3>&
>(_v);
69 if (std::abs(w[0]) >= std::abs(w[1])) {
70 inv_length = (T)1.0 / sqrt(w[0] * w[0] + w[2] * w[2]);
71 u[0] = -w[2] * inv_length;
73 u[2] = w[0] * inv_length;
75 v[1] = w[2] * u[0] - w[0] * u[2];
78 inv_length = (T)1.0 / sqrt(w[1] * w[1] + w[2] * w[2]);
80 u[1] = w[2] * inv_length;
81 u[2] = -w[1] * inv_length;
82 v[0] = w[1] * u[2] - w[2] * u[1];
91 const Eigen::MatrixBase<OtherDerived>& t1,
92 const Eigen::MatrixBase<Derived>& R2,
93 const Eigen::MatrixBase<OtherDerived>& t2,
94 const Eigen::MatrixBase<Derived>& R,
95 const Eigen::MatrixBase<OtherDerived>& t) {
96 const_cast<Eigen::MatrixBase<Derived>&
>(R) = R1.transpose() * R2;
97 const_cast<Eigen::MatrixBase<OtherDerived>&
>(t) = R1.transpose() * (t2 - t1);
103void eigen(
const Eigen::MatrixBase<Derived>& m,
104 typename Derived::Scalar dout[3], Vector* vout) {
105 typedef typename Derived::Scalar S;
106 Derived R(m.derived());
109 S tresh, theta, tau, t, sm, s, h, g, c;
113 S v[3][3] = {{1, 0, 0}, {0, 1, 0}, {0, 0, 1}};
116 for (ip = 0; ip < n; ++ip) {
117 b[ip] = d[ip] = R(ip, ip);
121 for (i = 0; i < 50; ++i) {
123 for (ip = 0; ip < n; ++ip)
124 for (iq = ip + 1; iq < n; ++iq) sm += std::abs(R(ip, iq));
126 vout[0] << v[0][0], v[0][1], v[0][2];
127 vout[1] << v[1][0], v[1][1], v[1][2];
128 vout[2] << v[2][0], v[2][1], v[2][2];
136 tresh =
Scalar(0.2 * sm / (n * n));
140 for (ip = 0; ip < n; ++ip) {
141 for (iq = ip + 1; iq < n; ++iq) {
142 g =
Scalar(100) * std::abs(R(ip, iq));
143 if (i > 3 && std::abs(d[ip]) + g == std::abs(d[ip]) &&
144 std::abs(d[iq]) + g == std::abs(d[iq]))
146 else if (std::abs(R(ip, iq)) > tresh) {
148 if (std::abs(h) + g == std::abs(h))
151 theta =
Scalar(0.5) * h / (R(ip, iq));
152 t = 1 / (std::abs(theta) + std::sqrt(1 + theta * theta));
153 if (theta < 0.0) t = -t;
155 c = 1 / std::sqrt(1 + t * t);
164 for (j = 0; j < ip; ++j) {
167 R(j, ip) = g - s * (h + g * tau);
168 R(j, iq) = h + s * (g - h * tau);
170 for (j = ip + 1; j < iq; ++j) {
173 R(ip, j) = g - s * (h + g * tau);
174 R(j, iq) = h + s * (g - h * tau);
176 for (j = iq + 1; j < n; ++j) {
179 R(ip, j) = g - s * (h + g * tau);
180 R(iq, j) = h + s * (g - h * tau);
182 for (j = 0; j < n; ++j) {
185 v[j][ip] = g - s * (h + g * tau);
186 v[j][iq] = h + s * (g - h * tau);
191 for (ip = 0; ip < n; ++ip) {
198 std::cerr <<
"eigen: too many iterations in Jacobi transform." << std::endl;
void eigen(const Eigen::MatrixBase< Derived > &m, typename Derived::Scalar dout[3], Vector *vout)
compute the eigen vector and eigen vector of a matrix. dout is the eigen values, vout is the eigen ve...
Definition tools.h:103
void relativeTransform(const Eigen::MatrixBase< Derived > &R1, const Eigen::MatrixBase< OtherDerived > &t1, const Eigen::MatrixBase< Derived > &R2, const Eigen::MatrixBase< OtherDerived > &t2, const Eigen::MatrixBase< Derived > &R, const Eigen::MatrixBase< OtherDerived > &t)
Definition tools.h:90