OpenWalnut  1.2.5
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends
WLinearAlgebraFunctions.h
00001 //---------------------------------------------------------------------------
00002 //
00003 // Project: OpenWalnut ( http://www.openwalnut.org )
00004 //
00005 // Copyright 2009 OpenWalnut Community, BSV@Uni-Leipzig and CNCF@MPI-CBS
00006 // For more information see http://www.openwalnut.org/copying
00007 //
00008 // This file is part of OpenWalnut.
00009 //
00010 // OpenWalnut is free software: you can redistribute it and/or modify
00011 // it under the terms of the GNU Lesser General Public License as published by
00012 // the Free Software Foundation, either version 3 of the License, or
00013 // (at your option) any later version.
00014 //
00015 // OpenWalnut is distributed in the hope that it will be useful,
00016 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00017 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00018 // GNU Lesser General Public License for more details.
00019 //
00020 // You should have received a copy of the GNU Lesser General Public License
00021 // along with OpenWalnut. If not, see <http://www.gnu.org/licenses/>.
00022 //
00023 //---------------------------------------------------------------------------
00024 
00025 #ifndef WLINEARALGEBRAFUNCTIONS_H
00026 #define WLINEARALGEBRAFUNCTIONS_H
00027 
00028 #include "../WExportCommon.h"
00029 #include "WMatrix.h"
00030 #include "linearAlgebra/WLinearAlgebra.h"
00031 
00032 template< typename > class WMatrix;
00033 
00034 /**
00035  * helper routine to multiply a 3x3 matrix with a vector
00036  *
00037  * \param mat 3x3 matrix
00038  * \param vec vector
00039  */
00040 WVector3d OWCOMMON_EXPORT multMatrixWithVector3D( WMatrix<double> mat, WVector3d vec );
00041 
00042 /**
00043  * Applies a coordinate transformation in homogenous coordinates to a vector.
00044  * This differs from transformPosition3DWithMatrix4D in that it DOES NOT incorporate the translation
00045  *
00046  * \param mat 4x4 matrix
00047  * \param vec vector
00048  */
00049 WVector3d OWCOMMON_EXPORT transformVector3DWithMatrix4D( WMatrix<double> mat, WVector3d vec );
00050 
00051 /**
00052  * Applies a coordinate transformation in homogenous coordinates to a position.
00053  * This differs from transformVector3DWithMatrix4D in that it incorporates the translation.
00054  *
00055  * \param mat 4x4 matrix
00056  * \param vec vector
00057  */
00058 WPosition OWCOMMON_EXPORT transformPosition3DWithMatrix4D( WMatrix<double> mat, WPosition vec );
00059 
00060 /**
00061  * helper routine to invert a 3x3 matrix
00062  *
00063  * \param mat 3x3 matrix
00064  *
00065  * \return inverted 3x3 matrix
00066  */
00067 WMatrix<double> OWCOMMON_EXPORT invertMatrix3x3( WMatrix<double> mat );
00068 
00069 /**
00070  * helper routine to invert a 4x4 matrix
00071  *
00072  * \param mat 4x4 matrix
00073  *
00074  * \return inverted 4x4 matrix
00075  */
00076 WMatrix<double> OWCOMMON_EXPORT invertMatrix4x4( WMatrix<double> mat );
00077 
00078 /**
00079  * Checks if the given two vectors are linearly independent.
00080  *
00081  * \param u First vector
00082  * \param v Second vector
00083  *
00084  * \return True if they are linear independent.
00085  *
00086  * \note This check is performed with the cross product != (0,0,0) but in numerical stability with FLT_EPS.
00087  */
00088 bool OWCOMMON_EXPORT linearIndependent( const WVector3d& u, const WVector3d& v );
00089 
00090 /**
00091  * Computes the SVD for the Matrix \param A
00092  *
00093  * A=U*S*V^T
00094  *
00095  * \param A Input Matrix
00096  * \param U Output Matrix
00097  * \param S Output of the entries in the diagonal matrix
00098  * \param V Output Matrix
00099  *
00100  */
00101 void OWCOMMON_EXPORT computeSVD( const WMatrix<double>& A, WMatrix<double>& U, WMatrix<double>& V, WValue<double>& S );
00102 
00103 /**
00104  * Calculates for a matrix the pseudo inverse.
00105  *
00106  * \param input Matrix to invert
00107  *
00108  * \return Inverted Matrix
00109  *
00110  */
00111 WMatrix<double> OWCOMMON_EXPORT pseudoInverse( const WMatrix<double>& input );
00112 
00113 #endif  // WLINEARALGEBRAFUNCTIONS_H
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends