|
@@ -12,17 +12,20 @@
|
|
|
#include <igl/polar_dec.h>
|
|
|
#include <igl/polar_svd.h>
|
|
|
#include <igl/matlab_format.h>
|
|
|
+#include <igl/C_STR.h>
|
|
|
#include <iostream>
|
|
|
|
|
|
template <typename DerivedS, typename DerivedD>
|
|
|
IGL_INLINE void igl::fit_rotations(
|
|
|
const Eigen::PlainObjectBase<DerivedS> & S,
|
|
|
+ const bool single_precision,
|
|
|
Eigen::PlainObjectBase<DerivedD> & R)
|
|
|
{
|
|
|
using namespace std;
|
|
|
const int dim = S.cols();
|
|
|
const int nr = S.rows()/dim;
|
|
|
assert(nr * dim == S.rows());
|
|
|
+ assert(dim == 3);
|
|
|
|
|
|
// resize output
|
|
|
R.resize(dim,dim*nr); // hopefully no op (should be already allocated)
|
|
@@ -41,12 +44,29 @@ IGL_INLINE void igl::fit_rotations(
|
|
|
si(i,j) = S(i*nr+r,j);
|
|
|
}
|
|
|
}
|
|
|
- Eigen::Matrix<typename DerivedD::Scalar,3,3> ri;
|
|
|
- Eigen::Matrix<typename DerivedD::Scalar,3,3> ti;
|
|
|
- polar_svd3x3(si, ri);
|
|
|
+ typedef Eigen::Matrix<typename DerivedD::Scalar,3,3> Mat3;
|
|
|
+ typedef Eigen::Matrix<typename DerivedD::Scalar,3,1> Vec3;
|
|
|
+ Mat3 ri;
|
|
|
+ if(single_precision)
|
|
|
+ {
|
|
|
+ polar_svd3x3(si, ri);
|
|
|
+ }else
|
|
|
+ {
|
|
|
+ Mat3 ti,ui,vi;
|
|
|
+ Vec3 _;
|
|
|
+ igl::polar_svd(si,ri,ti,ui,_,vi);
|
|
|
+ // Check for reflection
|
|
|
+ if(ri.determinant() < 0)
|
|
|
+ {
|
|
|
+ vi.col(1) *= -1.;
|
|
|
+ ri = ui * vi.transpose();
|
|
|
+ }
|
|
|
+ }
|
|
|
assert(ri.determinant() >= 0);
|
|
|
// Not sure why polar_dec computes transpose...
|
|
|
R.block(0,r*dim,dim,dim) = ri.block(0,0,dim,dim).transpose();
|
|
|
+ //cout<<matlab_format(si,C_STR("si_"<<r))<<endl;
|
|
|
+ //cout<<matlab_format(ri.transpose().eval(),C_STR("ri_"<<r))<<endl;
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -81,7 +101,6 @@ IGL_INLINE void igl::fit_rotations_planar(
|
|
|
Mat2 ri,ti,ui,vi;
|
|
|
Vec2 _;
|
|
|
igl::polar_svd(si,ri,ti,ui,_,vi);
|
|
|
-
|
|
|
#ifndef FIT_ROTATIONS_ALLOW_FLIPS
|
|
|
// Check for reflection
|
|
|
if(ri.determinant() < 0)
|
|
@@ -206,7 +225,7 @@ IGL_INLINE void igl::fit_rotations_AVX(
|
|
|
|
|
|
#ifndef IGL_HEADER_ONLY
|
|
|
// Explicit template instanciation
|
|
|
-template void igl::fit_rotations<Eigen::Matrix<double, -1, -1, 0, -1, -1>, Eigen::Matrix<double, -1, -1, 0, -1, -1> >(Eigen::PlainObjectBase<Eigen::Matrix<double, -1, -1, 0, -1, -1> > const&, Eigen::PlainObjectBase<Eigen::Matrix<double, -1, -1, 0, -1, -1> >&);
|
|
|
+template void igl::fit_rotations<Eigen::Matrix<double, -1, -1, 0, -1, -1>, Eigen::Matrix<double, -1, -1, 0, -1, -1> >(Eigen::PlainObjectBase<Eigen::Matrix<double, -1, -1, 0, -1, -1> > const&, bool, Eigen::PlainObjectBase<Eigen::Matrix<double, -1, -1, 0, -1, -1> >&);
|
|
|
template void igl::fit_rotations_planar<Eigen::Matrix<double, -1, -1, 0, -1, -1>, Eigen::Matrix<double, -1, -1, 0, -1, -1> >(Eigen::PlainObjectBase<Eigen::Matrix<double, -1, -1, 0, -1, -1> > const&, Eigen::PlainObjectBase<Eigen::Matrix<double, -1, -1, 0, -1, -1> >&);
|
|
|
template void igl::fit_rotations_planar<Eigen::Matrix<float, -1, -1, 0, -1, -1>, Eigen::Matrix<float, -1, -1, 0, -1, -1> >(Eigen::PlainObjectBase<Eigen::Matrix<float, -1, -1, 0, -1, -1> > const&, Eigen::PlainObjectBase<Eigen::Matrix<float, -1, -1, 0, -1, -1> >&);
|
|
|
#endif
|