polar_decomposition.h
Go to the documentation of this file.
00001 /****************************************************************************
00002 * VCGLib                                                            o o     *
00003 * Visual and Computer Graphics Library                            o     o   *
00004 *                                                                _   O  _   *
00005 * Copyright(C) 2004                                                \/)\/    *
00006 * Visual Computing Lab                                            /\/|      *
00007 * ISTI - Italian National Research Council                           |      *
00008 *                                                                    \      *
00009 * All rights reserved.                                                      *
00010 *                                                                           *
00011 * This program is free software; you can redistribute it and/or modify      *   
00012 * it under the terms of the GNU General Public License as published by      *
00013 * the Free Software Foundation; either version 2 of the License, or         *
00014 * (at your option) any later version.                                       *
00015 *                                                                           *
00016 * This program is distributed in the hope that it will be useful,           *
00017 * but WITHOUT ANY WARRANTY; without even the implied warranty of            *
00018 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the             *
00019 * GNU General Public License (http://www.gnu.org/licenses/gpl.txt)          *
00020 * for more details.                                                         *
00021 *                                                                           *
00022 ****************************************************************************/
00023 #ifndef POLAR_DECOMPOSITION_VCG
00024 #define POLAR_DECOMPOSITION_VCG
00025 
00026 
00027 #include <vcg/math/matrix33.h>
00028 #include <vcg/math/matrix44.h>
00029 #include <eigenlib/Eigen/Dense>
00030 #include <eigenlib/Eigen/SVD>
00031 
00032 namespace vcg{
00033 
00035         /* @{ */
00038 template <class S>
00039 void RotationalPartByPolarDecomposition( const vcg::Matrix33<S> & m, vcg::Matrix33<S> &r ){
00040 
00041         Eigen::Matrix<S,3,3> tmp,s;
00042 
00043         r.setZero();
00044         s.setZero();
00045 
00046         tmp = m*m.transpose();
00047 
00048         Eigen::Matrix<S,3,3> res;
00049         Eigen::Matrix<S,3,3> e;
00050 
00051         bool ss = SingularValueDecomposition<vcg::Matrix33<S> >(tmp,&e[0],res);
00052 
00053     Eigen::JacobiSVD<Eigen::MatrixXd> svd(A);
00054     sol=svd.solve(b);
00055 
00056         e[0]=math::Sqrt(e[0]);
00057         e[1]=math::Sqrt(e[1]);
00058         e[2]=math::Sqrt(e[2]);
00059         tmp = tmp*e.asDiagonal()*res.transpose();
00060 
00061         bool s1 = SingularValueDecomposition<vcg::Matrix33<S> >(tmp,&e[0],res.transpose());
00062         e[0]=1/e[0];
00063         e[1]=1/e[1];
00064         e[2]=1/e[2];
00065 
00066         tmp = res*e.asDiagonal()*tmp.transpose();
00067         r = m*tmp;
00068 }
00069 
00071 };
00072 #endif


shape_reconstruction
Author(s): Roberto Martín-Martín
autogenerated on Sat Jun 8 2019 18:34:27