Main Page   Modules   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Namespace Members   Compound Members   File Members   Related Pages  

Trafo.h

Go to the documentation of this file.
00001 // Copyright NVIDIA Corporation 2002-2004
00002 // TO THE MAXIMUM EXTENT PERMITTED BY APPLICABLE LAW, THIS SOFTWARE IS PROVIDED
00003 // *AS IS* AND NVIDIA AND ITS SUPPLIERS DISCLAIM ALL WARRANTIES, EITHER EXPRESS
00004 // OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, IMPLIED WARRANTIES OF MERCHANTABILITY
00005 // AND FITNESS FOR A PARTICULAR PURPOSE.  IN NO EVENT SHALL NVIDIA OR ITS SUPPLIERS
00006 // BE LIABLE FOR ANY SPECIAL, INCIDENTAL, INDIRECT, OR CONSEQUENTIAL DAMAGES
00007 // WHATSOEVER (INCLUDING, WITHOUT LIMITATION, DAMAGES FOR LOSS OF BUSINESS PROFITS,
00008 // BUSINESS INTERRUPTION, LOSS OF BUSINESS INFORMATION, OR ANY OTHER PECUNIARY LOSS)
00009 // ARISING OUT OF THE USE OF OR INABILITY TO USE THIS SOFTWARE, EVEN IF NVIDIA HAS
00010 // BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES 
00011 
00012 #pragma once
00013 
00015 #include "nvsgcommon.h"
00016 
00017 #include "nvmath/Mat44f.h"
00018 #include "nvmath/Quatf.h"
00019 
00020 namespace nvmath
00021 {
00023 
00025   class Trafo
00026   {
00027     public:
00029       NVSG_API Trafo( void );
00030 
00032 
00033       NVSG_API Mat44f getInverse( void ) const;
00034 
00036 
00037       NVSG_API const Vec3f & getCenter( void ) const;
00038 
00040 
00041       NVSG_API const Quatf & getOrientation( void ) const;
00042 
00044 
00045       NVSG_API const Vec3f & getScaling( void ) const;
00046 
00048 
00049       NVSG_API Mat44f getMatrix( void ) const;
00050 
00052 
00053       NVSG_API const Vec3f & getTranslation( void ) const;
00054 
00056       NVSG_API void setCenter( const Vec3f &center              
00057                              );
00058 
00060       NVSG_API void setIdentity( void );
00061 
00063       NVSG_API void setOrientation( const Quatf &orientation    
00064                                   );
00065 
00067       NVSG_API void setScaling( const Vec3f &scaling            
00068                               );
00069 
00071       NVSG_API void setTranslation( const Vec3f &translation    
00072                                   );
00073 
00074     private:
00075       Vec3f   m_center;             
00076       Quatf   m_orientation;        
00077       Vec3f   m_scaling;            
00078       Vec3f   m_translation;        
00079   };
00080 
00081   // - - - - -  - - - - - - - - - - - - - - - - - - - - - - - - - - - - 
00082   // non-member functions
00083   // - - - - -  - - - - - - - - - - - - - - - - - - - - - - - - - - - - 
00087   inline Trafo lerp( float alpha      
00088                    , const Trafo &t0  
00089                    , const Trafo &t1  
00090                    )
00091   {
00092     Trafo t;
00093     t.setCenter( lerp( alpha, t0.getCenter(), t1.getCenter() ) );
00094     t.setOrientation( lerp( alpha, t0.getOrientation(), t1.getOrientation() ) );
00095     t.setScaling( lerp( alpha, t0.getScaling(), t1.getScaling() ) );
00096     t.setTranslation( lerp( alpha, t0.getTranslation(), t1.getTranslation() ) );
00097     return( t );
00098   }
00099 
00100   // - - - - -  - - - - - - - - - - - - - - - - - - - - - - - - - - - - 
00101   // inlines
00102   // - - - - -  - - - - - - - - - - - - - - - - - - - - - - - - - - - - 
00103   inline Trafo::Trafo( void )
00104     : m_center( Vec3f( 0.0f, 0.0f, 0.0f ) )
00105     , m_orientation( Quatf( 0.0f, 0.0f, 0.0f, 1.0f ) )
00106     , m_scaling( Vec3f( 1.0f, 1.0f, 1.0f ) )
00107     , m_translation( Vec3f( 0.0f, 0.0f, 0.0f ) )
00108   {
00109   };
00110 
00111   inline const Vec3f & Trafo::getCenter( void ) const
00112   {
00113     return( m_center );
00114   }
00115 
00116   inline const Quatf & Trafo::getOrientation( void ) const
00117   {
00118     return( m_orientation );
00119   }
00120 
00121   inline const Vec3f & Trafo::getScaling( void ) const
00122   {
00123     return( m_scaling );
00124   }
00125 
00126   inline const Vec3f & Trafo::getTranslation( void ) const
00127   {
00128     return( m_translation );
00129   }
00130 
00131   inline void Trafo::setCenter( const Vec3f &center )
00132   {
00133     m_center = center;
00134   }
00135 
00136   inline void Trafo::setIdentity( void )
00137   {
00138     m_center = Vec3f( 0.0f, 0.0f, 0.0f );
00139     m_orientation = Quatf( 0.0f, 0.0f, 0.0f, 1.0f );
00140     m_scaling = Vec3f( 1.0f, 1.0f, 1.0f );
00141     m_translation = Vec3f( 0.0f, 0.0f, 0.0f );
00142   }
00143 
00144   inline void Trafo::setOrientation( const Quatf &orientation )
00145   {
00146     __ASSERT( isNormalized( orientation ) );
00147     m_orientation = orientation;
00148   }
00149 
00150   inline void Trafo::setScaling( const Vec3f &scaling )
00151   {
00152     m_scaling = scaling;
00153   }
00154 
00155   inline void Trafo::setTranslation( const Vec3f &translation )
00156   {
00157     m_translation = translation;
00158   }
00159 }

Generated on Tue Mar 1 13:19:19 2005 for NVSGSDK by NVIDIA