Spring< T > Class Template Reference

#include <TAPsSpring.hpp>

Collaboration diagram for Spring< T >:

Collaboration graph
[legend]

List of all members.

Public Member Functions

GetConstantK () const
GetCurrentLength () const
GetDampingD () const
Vector3< T > GetForce () const
Particle< T > & GetParticleOne ()
Particle< T > & GetParticleTwo ()
GetRestLengthL () const
 Spring (Particle< T > &P1, Particle< T > &P2, T k, T d)
 Spring (Particle< T > &P1, Particle< T > &P2, T k, T d, T l)
 ~Spring ()

Private Member Functions

Spring< T > const & operator= (Spring< T > const &S)

Private Attributes

Particle< T > & m_rcP1
Particle< T > & m_rcP2
m_tD
m_tK
m_tL

Friends

class Cloth< T >
class DeformMesh< T >
std::ostream & operator<< (std::ostream &output, Spring< T > const &S)


Detailed Description

template<typename T>
class Spring< T >

Definition at line 22 of file TAPsSpring.hpp.


Constructor & Destructor Documentation

template<typename T>
BEGIN_NAMESPACE_TAPs Spring< T >::Spring ( Particle< T > &  P1,
Particle< T > &  P2,
k,
d,
l 
) [inline]

Definition at line 22 of file TAPsSpring.cpp.

00026     : 
00027     m_rcP1( P1 ), 
00028     m_rcP2( P2 ), 
00029     m_tK( k ), 
00030     m_tD( d ), 
00031     m_tL( l )
00032 {}

template<typename T>
Spring< T >::Spring ( Particle< T > &  P1,
Particle< T > &  P2,
k,
d 
) [inline]

Definition at line 37 of file TAPsSpring.cpp.

00041     : 
00042     m_rcP1( P1 ), 
00043     m_rcP2( P2 ), 
00044     m_tK( k ), 
00045     m_tD( d )
00046 {
00047     T x = P2.GetPosition().GetX() - P1.GetPosition().GetX();
00048     T y = P2.GetPosition().GetY() - P1.GetPosition().GetY();
00049     T z = P2.GetPosition().GetZ() - P1.GetPosition().GetZ();
00050     m_tL = sqrt( x*x + y*y + z*z );
00051 }

template<typename T>
Spring< T >::~Spring (  )  [inline]

Definition at line 55 of file TAPsSpring.cpp.

00056 {}


Member Function Documentation

template<typename T>
T Spring< T >::GetConstantK (  )  const [inline]

Definition at line 97 of file TAPsSpring.cpp.

00098 {   return m_tK;    }

template<typename T>
T Spring< T >::GetCurrentLength (  )  const [inline]

Definition at line 112 of file TAPsSpring.cpp.

00113 {   return ( m_rcP1.GetPosition() - m_rcP2.GetPosition() ).Length();    }

template<typename T>
T Spring< T >::GetDampingD (  )  const [inline]

Definition at line 102 of file TAPsSpring.cpp.

00103 {   return m_tD;    }

template<typename T>
Vector3< T > Spring< T >::GetForce (  )  const [inline]

Definition at line 62 of file TAPsSpring.cpp.

00063 {
00064     // Local Variables ---------------------------------------------------------
00065     // spring current length vector
00066     Vector3<T> cL = ( m_rcP1.GetPosition() - m_rcP2.GetPosition() );
00067     // spring current length scalar
00068     T scl = cL.Length();
00069     // velocity difference of the two particles linked by the spring
00070     Vector3<T> V = ( m_rcP1.GetVelocity() - m_rcP2.GetVelocity() );
00071 
00072     // F1 = -{Ks(l - r) + Kd[(V1-V2)*L]/l}*L/l
00073     // F2 = -F1
00074     //   where Ks = spring stiffness, Kd = spring damping,
00075     //     V1 and V2 are velocity of particles linked by the spring
00076     //     r = spring rest length
00077     //     L = vector of difference of positions of particle#1 and #2
00078     //     l = magnitude of L
00079     return -( (m_tK * (scl - m_tL)) +  (m_tD * ((V*cL) / scl)) ) * (cL / scl);
00080 }

template<typename T>
Particle< T > & Spring< T >::GetParticleOne (  )  [inline]

Definition at line 87 of file TAPsSpring.cpp.

00088 {   return m_rcP1;  }

template<typename T>
Particle< T > & Spring< T >::GetParticleTwo (  )  [inline]

Definition at line 92 of file TAPsSpring.cpp.

00093 {   return m_rcP2;  }

template<typename T>
T Spring< T >::GetRestLengthL (  )  const [inline]

Definition at line 107 of file TAPsSpring.cpp.

00108 {   return m_tL;    }

template<typename T>
Spring<T> const& Spring< T >::operator= ( Spring< T > const &  S  )  [private]


Friends And Related Function Documentation

template<typename T>
friend class Cloth< T > [friend]

Definition at line 27 of file TAPsSpring.hpp.

template<typename T>
friend class DeformMesh< T > [friend]

Definition at line 26 of file TAPsSpring.hpp.

template<typename T>
std::ostream& operator<< ( std::ostream &  output,
Spring< T > const &  S 
) [friend]

Definition at line 30 of file TAPsSpring.hpp.

00031     {
00032         output  << "Spring<" << typeid(T).name() << "> ==> "
00033                 << "\n  -------START--SPRING--INFO-------"
00034                 << "\n  Particle #1: " << S.m_rcP1
00035                 << "\n  Particle #2: " << S.m_rcP2
00036                 << "\n  K Constant:  " << S.m_tK
00037                 << "\n  D Damping:   " << S.m_tD
00038                 << "\n  L Length:    " << S.m_tL
00039                 << "\n  Current Length: " << S.GetCurrentLength()
00040                 << "\n  Force:       " << S.GetForce()
00041                 << "\n  --------END--SPRING--INFO--------\n";
00042         return output;
00043     }


Member Data Documentation

template<typename T>
Particle<T>& Spring< T >::m_rcP1 [private]

Definition at line 47 of file TAPsSpring.hpp.

template<typename T>
Particle<T>& Spring< T >::m_rcP2 [private]

Definition at line 48 of file TAPsSpring.hpp.

template<typename T>
T Spring< T >::m_tD [private]

Definition at line 50 of file TAPsSpring.hpp.

template<typename T>
T Spring< T >::m_tK [private]

Definition at line 49 of file TAPsSpring.hpp.

template<typename T>
T Spring< T >::m_tL [private]

Definition at line 51 of file TAPsSpring.hpp.


The documentation for this class was generated from the following files:

Generated on Mon Oct 13 11:45:56 2008 for TAPs by  doxygen 1.5.6