![]() |
TAPs 0.7.7.3
|
00001 /****************************************************************************** 00002 TAPsParticle.hpp 00003 ******************************************************************************/ 00007 /****************************************************************************** 00008 SUKITTI PUNAK (09/15/2004) 00009 UPDATE (08/06/2010) 00010 ******************************************************************************/ 00011 #include "TAPsParticle.hpp" 00012 // Using Inclusion Model (i.e. definitions are included in declarations) 00013 // (this name.cpp is included in name.hpp) 00014 // Each friend is defined directly inside its declaration. 00015 00016 BEGIN_NAMESPACE_TAPs 00017 //============================================================================= 00018 // Constructors and Destructor 00019 //----------------------------------------------------------------------------- 00020 // Particle Default Constructor 00021 template <typename T> 00022 Particle<T>::Particle () : ParticleBase<T>() 00023 {} 00024 //----------------------------------------------------------------------------- 00025 // Particle Constructor 00026 template <typename T> 00027 Particle<T>::Particle 00028 ( 00029 T mass, 00030 Vector3<T> const & vPosition, 00031 Vector3<T> const & vVelocity, 00032 Vector3<T> const & vAcceleration, 00033 Vector3<T> const & vForce, 00034 bool fixed 00035 ) : ParticleBase<T>( mass, vVelocity, vAcceleration, vForce, fixed ) 00036 , m_vtPosit( vPosition ) 00037 , m_vtNormal( 0, 0, 1 ) 00038 {} 00039 //----------------------------------------------------------------------------- 00040 // Particle Copy Constructor 00041 template <typename T> 00042 Particle<T>::Particle ( Particle<T> const &P ) 00043 : ParticleBase<T>( P ) 00044 , m_vtPosit( P.m_vtPosit ) 00045 , m_vtNormal( P.m_vtNormal ) 00046 {} 00047 //----------------------------------------------------------------------------- 00048 // Particle Destructor 00049 template <typename T> 00050 Particle<T>::~Particle () 00051 {} 00052 //----------------------------------------------------------------------------- 00053 // Return this object info as a string 00054 template <typename T> 00055 std::string Particle<T>::StrInfo () const 00056 { 00057 std::stringstream ss; 00058 ss << "Particle<" << typeid(T).name() << "> ==> " 00059 << "\n Mass: " << GetMass() 00060 << "\n Normal: " << GetNormal() 00061 << "\n Position: " << GetPosition() 00062 << "\n Velocity: " << GetVelocity() 00063 << "\n Acceleration: " << GetAcceleration() 00064 << "\n Force: " << GetForce() 00065 << "\n Fix Status: " << ( GetFixStatus() == true ? "true" : "false" ) 00066 << "\n"; 00067 return ss.str(); 00068 } 00069 //----------------------------------------------------------------------------- 00070 //============================================================================= 00071 // Particle Assignment Operator 00072 //----------------------------------------------------------------------------- 00073 template <typename T> 00074 Particle<T> const & Particle<T>::operator= ( Particle<T> const &P ) 00075 { 00076 if ( this != &P ) 00077 { 00078 *(dynamic_cast< ParticleBase<T> * >( this )) = *(dynamic_cast< ParticleBase<T> const * >( &P )); 00079 m_vtNormal = P.m_vtNormal; 00080 m_vtPosit = P.m_vtPosit; 00081 } 00082 return *this; 00083 } 00084 //============================================================================= 00085 // Get/Set Functions 00086 //----------------------------------------------------------------------------- 00087 template <typename T> 00088 inline Vector3<T> const & Particle<T>::RefToNormal () const 00089 { return m_vtNormal; } 00090 //----------------------------------------------------------------------------- 00091 template <typename T> 00092 inline Vector3<T> & Particle<T>::RefToNormal () 00093 { return m_vtNormal; } 00094 //----------------------------------------------------------------------------- 00095 template <typename T> 00096 inline Vector3<T> const & Particle<T>::GetNormal () const 00097 { return m_vtNormal; } 00098 //----------------------------------------------------------------------------- 00099 template <typename T> 00100 inline void Particle<T>::SetNormal ( Vector3<T> const &v ) 00101 { m_vtNormal = v; } 00102 //----------------------------------------------------------------------------- 00103 template <typename T> 00104 inline void Particle<T>::SetNormal ( T x, T y, T z ) 00105 { m_vtNormal.SetXYZ( x, y, z ); } 00106 //----------------------------------------------------------------------------- 00107 template <typename T> 00108 inline Vector3<T> const & Particle<T>::RefToPosition () const 00109 { return m_vtPosit; } 00110 //----------------------------------------------------------------------------- 00111 template <typename T> 00112 inline Vector3<T> & Particle<T>::RefToPosition () 00113 { return m_vtPosit; } 00114 //----------------------------------------------------------------------------- 00115 template <typename T> 00116 inline Vector3<T> const & Particle<T>::GetPosition () const 00117 { return m_vtPosit; } 00118 //----------------------------------------------------------------------------- 00119 template <typename T> 00120 inline void Particle<T>::SetPosition ( Vector3<T> const &v ) 00121 { m_vtPosit = v; } 00122 //----------------------------------------------------------------------------- 00123 template <typename T> 00124 inline void Particle<T>::SetPosition ( T x, T y, T z ) 00125 { m_vtPosit.SetXYZ( x, y, z ); } 00126 //----------------------------------------------------------------------------- 00127 //============================================================================= 00128 END_NAMESPACE_TAPs 00129 //345678901234567890123456789012345678901234567890123456789012345678901234567890 00130 //--+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8