TAPs 0.7.7.3
TAPsSpringVertex.hpp
Go to the documentation of this file.
00001 /******************************************************************************
00002 TAPsSpringVertex.hpp
00003 
00004 SpringVertex class is a class for a spring connecting between two ParticleVertex.
00005 
00006 SUKITTI PUNAK   (11/08/2004)
00007 UPDATE          (11/08/2004)
00008 ******************************************************************************/
00009 #ifndef TAPs_SPRING_VERTEX_HPP
00010 #define TAPs_SPRING_VERTEX_HPP
00011 
00012 #include "TAPsParticleVertex.hpp"
00013 
00014 BEGIN_NAMESPACE_TAPs
00015 template <typename T>
00016 class SpringVertex {
00017 //=============================================================================
00018     //-------------------------------------------------------------------------
00019     // put it through ostream
00020     friend std::ostream &operator<< ( std::ostream &output, SpringVertex<T> const &S )
00021     {
00022         output  << "Spring<" << typeid(T).name() << "> ==> "
00023                 << "\n  -------START--SPRING_VERTEX--INFO-------"
00024                 << "\n  ParticleVertex #1: " << S.m_rcP1
00025                 << "\n  ParticleVertex #2: " << S.m_rcP2
00026                 << "\n  K Constant: " << S.m_tK
00027                 << "\n  D Damping:  " << S.m_tD
00028                 << "\n  L Length:   " << S.m_tL
00029                 << "\n  Force:      " << S.GetForce()
00030                 << "\n  Current Length: " << S.GetCurrentLength()
00031                 << "\n  --------END--SPRING_VERTEX--INFO--------\n";
00032         return output;
00033     }
00034 //-----------------------------------------------------------------------------
00035 private:
00036     // Data Members     ========================================================
00037     ParticleVertex<T> & m_rcP1; // reference to connected ParticleVertex #1
00038     ParticleVertex<T> & m_rcP2; // reference to connected ParticleVertex #2
00039     T                   m_tK;   // tensile spring constant (K)
00040     T                   m_tD;   // damping factor (D)
00041     T                   m_tL;   // rest length of spring (L)
00042     //-------------------------------------------------------------------------
00043 public:
00044     // Member Functions     ====================================================
00045     SpringVertex ( 
00046         ParticleVertex<T> &P1, 
00047         ParticleVertex<T> &P2, 
00048         T k, T d, T l );        // constructor
00049     SpringVertex ( 
00050         ParticleVertex<T> &P1, 
00051         ParticleVertex<T> &P2, 
00052         T k, T d );             // constructor
00053     ~SpringVertex ();           // destructor
00054     //-------------------------------------------------------------------------
00055     // Calculate and Return the (Internal) Force of a Spring
00056     Vector3<T> GetForce () const;
00057     //-------------------------------------------------------------------------
00058     // Get/Set Functions
00059     // REMARK: No const for Particle<T> & and const after the get fns
00060     //         so that the return ref can be modified.
00061     inline ParticleVertex<T> & GetParticleVertexOne ();
00062     inline ParticleVertex<T> & GetParticleVertexTwo ();
00063     inline T GetConstantK () const;
00064     inline T GetDampingD () const;
00065     inline T GetRestLengthL () const;
00066     inline T GetCurrentLength () const;
00067     //-------------------------------------------------------------------------
00068 private:
00069     // Prohibited Functions ====================================================
00070     // Since a spring refers to two particles, therefore
00071     // Copy Constructor and Assignment Operator are prohibited.
00072     SpringVertex<T> const & operator= ( SpringVertex<T> const &S ); // assignment operator
00073     //-------------------------------------------------------------------------
00074 }; // END CLASS Spring
00075 //=============================================================================
00076 END_NAMESPACE_TAPs
00077 //-----------------------------------------------------------------------------
00078 // Include definition if TAPs_USE_EXPORT is not defined
00079 //#if !defined( TAPs_USE_EXPORT )
00080     #include "TAPsSpringVertex.cpp"
00081 //#endif
00082 //-----------------------------------------------------------------------------
00083 #endif
00084 //345678901234567890123456789012345678901234567890123456789012345678901234567890
00085 //--+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines