TAPs 0.7.7.3
TAPsPointMass.hpp
Go to the documentation of this file.
00001 /******************************************************************************
00002 TAPsPointMass.hpp
00003 
00004 PointMass class is a class for a static point mass reside in 3D.
00005 
00006 SUKITTI PUNAK   (09/16/2010)
00007 UPDATE          (10/08/2010)
00008 ******************************************************************************/
00009 #ifndef TAPs_POINT_MASS_HPP
00010 #define TAPs_POINT_MASS_HPP
00011 
00018 #include "../Core/TAPsCGMath.hpp"
00019 #include "../DataStructure/TAPsSimulationFlags.hpp"
00020 
00021 BEGIN_NAMESPACE_TAPs
00022 //=============================================================================
00023 // Forward Class Declarations
00024 //=============================================================================
00025 template <typename T>
00026 class PointMass {
00027 //=============================================================================
00028 //-----------------------------------------------------------------------------
00029 // Friend Function
00030 friend std::ostream & operator<< ( std::ostream &output, PointMass<T> const &P )
00031 {
00032     return output << P.StrInfo();
00033 }
00034 //-----------------------------------------------------------------------------
00035 
00036 //=============================================================================
00037 public:
00038     // Member Functions -------------------------------------------------------
00039 
00041     enum Type {
00042         TYPE_STATIC,                    
00043         TYPE_DYNAMIC,                   
00044         TYPE_DYNAMIC_WITH_ORIENTATION,  
00045     };
00046 
00048     PointMass ( bool bRandomValue = false );
00049 
00051     PointMass ( 
00052         T                   mass,
00053         T                   radius          = 1,
00054         Vector3<T> const &  vPosition       = ZeroVector,
00055         DS::SimulationFlags const & flags   = DS::SimulationFlags()
00056     );
00057 
00059     PointMass ( Vector3<T> const & location );
00060 
00062     PointMass ( T const location[3] );
00063 
00065     PointMass ( T locX, T locY, T locZ );
00066 
00068     PointMass ( PointMass<T> const & P );
00069 
00071     ~PointMass ();
00072 
00074     virtual std::string StrInfo () const;
00075 
00077     inline virtual void DefaultValues ();
00078 
00080     inline virtual void RandomValues ();
00081 
00082     //-------------------------------------------------------------------------
00083     // Assignment Operator
00084     PointMass<T> const & operator= ( PointMass<T> const & P );
00085 
00086     //-------------------------------------------------------------------------
00087     // Get/Set Functions
00088 
00089     // Type ---------------------------------------------------------
00091     Type GetType () const   { return m_Type; }
00092 
00093     // Physics Properties -------------------------------------------
00095     inline T const & GetMass () const;
00097     inline T &  GetMass ();
00099     inline void SetMass ( T t );
00101     inline T const & GetSize () const;
00103     inline T &  GetSize ();
00105     inline void SetSize ( T t );
00107     inline Vector3<T> const & GetPosition () const;
00109     inline Vector3<T> & GetPosition ();
00111     inline void         SetPosition ( Vector3<T> const & v3 );
00113     inline void         SetPosition ( T x, T y, T z );
00114 
00115     //---------------------------------------------------------------
00116     // Functions for non-members (which should be overided by subclasses)
00117     //---------------------------------------------------------------
00119     inline virtual Vector3<T> const & GetVelocity () const  { return CGMath<T>::TempVector3; PrtWarningWithFileNameAndLineNumber( "No Op or No Effect Function is called"); }
00121     inline virtual Vector3<T> & GetVelocity ()  { return CGMath<T>::TempVector3; PrtWarningWithFileNameAndLineNumber( "No Op or No Effect Function is called"); }
00123     inline virtual void SetVelocity ( Vector3<T> const & v3 ) {}
00125     inline virtual void SetVelocity ( T x, T y, T z ) {}
00126 
00128     inline virtual Vector3<T> const & GetAcceleration () const  { return CGMath<T>::TempVector3; PrtWarningWithFileNameAndLineNumber( "No Op or No Effect Function is called"); }
00130     inline virtual Vector3<T> & GetAcceleration ()  { return CGMath<T>::TempVector3; PrtWarningWithFileNameAndLineNumber( "No Op or No Effect Function is called"); }
00132     inline virtual void SetAcceleration ( Vector3<T> const & v3 ) {}
00134     inline virtual void SetAcceleration ( T x, T y, T z ) {}
00135 
00137     inline virtual Vector3<T> const & GetForce () const { return CGMath<T>::TempVector3; PrtWarningWithFileNameAndLineNumber( "No Op or No Effect Function is called"); }
00139     inline virtual Vector3<T> & GetForce () { return CGMath<T>::TempVector3; PrtWarningWithFileNameAndLineNumber( "No Op or No Effect Function is called"); }
00141     inline virtual void SetForce ( Vector3<T> const & v3 ) {}
00143     inline virtual void SetForce ( T x, T y, T z ) {}
00144     //---------------------------------------------------------------
00145 
00146     // Constraints --------------------------------------------------
00147     
00148     // Get simulation flags
00149     inline DS::SimulationFlags const &  GetFlags () const;
00150     // Get simulation flags
00151     inline DS::SimulationFlags &        GetFlags ();
00152 
00153     //-------------------------------------------------------------------------
00154 
00155     //-------------------------------------------------------------------------
00156     // Data Members -----------------------------------------------------------
00157 //=============================================================================
00158 protected:
00159     // Member Functions -------------------------------------------------------
00160     // Data Members -----------------------------------------------------------
00161     // Physics Properties -------------------------------------------
00162     T           m_tMass;            
00163     T           m_tSize;            
00164     Vector3<T>  m_v3Position;       
00165     // Constraints --------------------------------------------------
00166     DS::SimulationFlags m_SimFlags;     
00167     // Type ---------------------------------------------------------
00168     Type        m_Type;             
00169 //=============================================================================
00170 private:
00171     // Member Functions -------------------------------------------------------
00172     // Data Members -----------------------------------------------------------
00173 //=============================================================================
00174 #if defined(__gl_h_) || defined(__GL_H__)
00175 public:
00177     virtual void Draw () const;
00179     virtual void Draw ( T scale ) const;
00180 #endif
00181 //=============================================================================
00182 }; // END CLASS PointMass
00183 //=============================================================================
00184 END_NAMESPACE_TAPs
00185 //-----------------------------------------------------------------------------
00186 #include "TAPsPointMass.cpp"
00187 //-----------------------------------------------------------------------------
00188 #endif
00189 //34567890123456789012345678901234567890123456789012345678901234567890123456789
00190 //--+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines