-
- inline TVector GetCenterOfGravity( ) const
- {
- TVector cog;
- if( S( 0 ) < this->m_M )
- {
- for( unsigned int d = 0; d < D; ++d )
- cog[ d ] = this->m_MP[ d ][ 0 ] / this->m_M;
- }
- else
- cog.Fill( S( 0 ) );
- return( cog );
- }
-
- inline void GetEigenAnalysis( TMatrix& pm, TVector& pv, TVector& r ) const
- {
- TMatrix I = this->GetInertia( );
-
- itk::SymmetricEigenAnalysis< TMatrix, TVector, TMatrix > eigen;
- eigen.SetDimension( D );
- eigen.SetOrderEigenMagnitudes( true );
- eigen.SetOrderEigenValues( 1 );
- eigen.ComputeEigenValuesAndVectors( I, pv, pm );
- pm = TMatrix( pm.GetTranspose( ) );
- S det = vnl_determinant( pm.GetVnlMatrix( ) );
- for( unsigned int d = 0; d < D; ++d )
- pm[ d ][ D - 1 ] *= det;
-
- if( D == 2 )
- {
- S coeff = S( 4 ) / this->m_M;
- r[ 0 ] = std::sqrt( std::fabs( coeff * pv[ 1 ] ) );
- r[ 1 ] = std::sqrt( std::fabs( coeff * pv[ 0 ] ) );
- }
- else if( D == 3 )
- {
- S coeff = S( 2.5 ) / this->m_M;
- r[ 0 ] = std::sqrt( std::fabs( coeff * ( pv[ 1 ] + pv[ 2 ] - pv[ 0 ] ) ) );
- r[ 1 ] = std::sqrt( std::fabs( coeff * ( pv[ 0 ] + pv[ 2 ] - pv[ 1 ] ) ) );
- r[ 2 ] = std::sqrt( std::fabs( coeff * ( pv[ 0 ] + pv[ 1 ] - pv[ 2 ] ) ) );
- }
- else
- r.Fill( S( 0 ) );
- }
-
- protected:
- InertiaTensorFunction( )
- : Superclass( )
- {
- this->Reset( );
- }
- virtual ~InertiaTensorFunction( )
- {
- }
-
- private:
- // Purposely not implemented.
- InertiaTensorFunction( const Self& );
- void operator=( const Self& );
-
- protected:
- S m_M;
- S m_MPP;
- _TInternalVector m_MP;
- _TInternalMatrix m_MPPT;
- };
-
- } // ecapseman
+ else
+ r.Fill( S( 0 ) );
+ }
+
+ protected:
+ InertiaTensorFunction( )
+ : Superclass( )
+ {
+ this->Reset( );
+ }
+ virtual ~InertiaTensorFunction( )
+ {
+ }
+
+ private:
+ // Purposely not implemented.
+ InertiaTensorFunction( const Self& );
+ void operator=( const Self& );
+
+ protected:
+ S m_M;
+ S m_MPP;
+ _TInternalVector m_MP;
+ _TInternalMatrix m_MPPT;
+ };
+
+ } // ecapseman