#include <TAPsSpringRef.hpp>

Public Member Functions | |
| void | CalAndSetForce () |
| T | GetConstantK () const |
| T | GetCurrentLength () const |
| T | GetDampingD () const |
| void | GetForce (Vector3< T > &F1, Vector3< T > &F2) const |
| Vector3< T > | GetForce1 () const |
| Vector3< T > | GetForce2 () const |
| ParticleRef< T > const & | GetParticleOne () const |
| ParticleRef< T > & | GetParticleOne () |
| ParticleRef< T > const & | GetParticleTwo () const |
| ParticleRef< T > & | GetParticleTwo () |
| T | GetRestLengthL () const |
| void | SetConstantK (T Ks) |
| void | SetDampingD (T Kd) |
| void | SetRestLengthL (T length) |
| SpringRef (ParticleRef< T > &P1, ParticleRef< T > &P2, T k, T d, T l, int hops=1) | |
| SpringRef (ParticleRef< T > &P1, ParticleRef< T > &P2, T k, T d, int hops=1) | |
| ~SpringRef () | |
Static Public Member Functions | |
| static void | SpringsCreation (HEVertexList< T > *meshVertex, std::list< int > &vertexNo, std::list< ParticleRef< T > > &particleList, T mass, std::list< SpringRef< T > > &springNo, T Ks, T Kd, int hopDistance=1) |
| static void | SpringsCreation (XVertex< T > *meshVertex, int *vertexNo, ParticleRef< T > *particleNo, T mass, SpringRef< T > *springNo, T Ks, T Kd, int hopDistance=1) |
| static void | SpringsCreation (Vertex< T > *meshVertex, int *vertexNo, ParticleRef< T > *particleNo, T mass, SpringRef< T > *springNo, T Ks, T Kd, int hopDistance=1) |
Private Member Functions | |
| SpringRef< T > const & | operator= (SpringRef< T > const &S) |
Private Attributes | |
| int | m_iNumHops |
| ParticleRef< T > * | m_refP1 |
| ParticleRef< T > * | m_refP2 |
| T | m_tD |
| T | m_tK |
| T | m_tL |
Friends | |
| std::ostream & | operator<< (std::ostream &output, SpringRef< T > const &S) |
Definition at line 19 of file TAPsSpringRef.hpp.
| SpringRef< T >::SpringRef | ( | ParticleRef< T > & | P1, | |
| ParticleRef< T > & | P2, | |||
| T | k, | |||
| T | d, | |||
| int | hops = 1 | |||
| ) | [inline] |
Definition at line 40 of file TAPsSpringRef.cpp.
00045 : 00046 m_refP1( &P1 ), 00047 m_refP2( &P2 ), 00048 m_tK( k ), 00049 m_tD( d ), 00050 m_iNumHops( hops ) 00051 { 00052 T x = P2.GetPosition().GetX() - P1.GetPosition().GetX(); 00053 T y = P2.GetPosition().GetY() - P1.GetPosition().GetY(); 00054 T z = P2.GetPosition().GetZ() - P1.GetPosition().GetZ(); 00055 m_tL = sqrt( x*x + y*y + z*z ); 00056 }
| BEGIN_NAMESPACE_TAPs SpringRef< T >::SpringRef | ( | ParticleRef< T > & | P1, | |
| ParticleRef< T > & | P2, | |||
| T | k, | |||
| T | d, | |||
| T | l, | |||
| int | hops = 1 | |||
| ) | [inline] |
Definition at line 23 of file TAPsSpringRef.cpp.
00028 : 00029 m_refP1( &P1 ), 00030 m_refP2( &P2 ), 00031 m_tK( k ), 00032 m_tD( d ), 00033 m_tL( l ), 00034 m_iNumHops( hops ) 00035 {}
| void SpringRef< T >::CalAndSetForce | ( | ) | [inline] |
Definition at line 184 of file TAPsSpringRef.cpp.
00185 { 00186 Vector3<T> F2 = GetForce2(); 00187 if ( m_refP2->GetFixStatus() ) { 00188 m_refP2->SetVelocity( 0, 0, 0 ); 00189 m_refP2->SetForce( 0, 0 , 0 ); 00190 } 00191 else { 00192 m_refP2->SetForce( m_refP2->GetForce() + F2 ); 00193 } 00194 if ( m_refP1->GetFixStatus() ) { 00195 m_refP1->SetVelocity( 0, 0, 0 ); 00196 m_refP1->SetForce( 0, 0 , 0 ); 00197 } 00198 else { 00199 m_refP1->SetForce( m_refP1->GetForce() - F2 ); 00200 } 00201 }
| T SpringRef< T >::GetConstantK | ( | ) | const [inline] |
| T SpringRef< T >::GetCurrentLength | ( | ) | const [inline] |
| T SpringRef< T >::GetDampingD | ( | ) | const [inline] |
| void SpringRef< T >::GetForce | ( | Vector3< T > & | F1, | |
| Vector3< T > & | F2 | |||
| ) | const [inline] |
Definition at line 175 of file TAPsSpringRef.cpp.
00176 { 00177 F2 = GetForce2(); 00178 F1 = -F2; 00179 }
Definition at line 67 of file TAPsSpringRef.cpp.
00068 { 00069 00070 std::cout << "OBSOLETED: GetForce1() should not be called" << std::endl; 00071 exit( 1 ); 00072 00073 // Not Home Spring 00074 if ( m_iNumHops > 0 ) { 00075 // Local Variables ------------------------------------------ 00076 // spring current length vector 00077 Vector3<T> cL = ( m_refP1->GetPosition() - m_refP2->GetPosition() ); 00078 // spring current length scalar 00079 T scl = cL.Length(); 00080 cL /= scl; // normalize the length vector 00081 // velocity difference of the two particles linked by the spring 00082 Vector3<T> V = ( m_refP1->GetVelocity() - m_refP2->GetVelocity() ); 00083 //----------------------------------------------------------- 00084 // Formula from Physically Based Modeling (Siggraph 2001 Course Note) 00085 // F1 = -{Ks(l - r) + Kd[(V1-V2)*L]/l}*L/l 00086 // F2 = -F1 00087 // where Ks = spring stiffness, Kd = spring damping, 00088 // V1 and V2 are velocity of particles linked by the spring 00089 // r = spring rest length 00090 // L = vector of difference of positions of particle#1 and #2 00091 // l = magnitude of L 00092 return ( ( m_tK * (scl - m_tL) ) + ( m_tD * V * cL ) ) * cL; 00093 } 00094 // Home Spring 00095 else { 00096 // Local Variables ------------------------------------------ 00097 // spring current length vector 00098 Vector3<T> cL = ( m_refP1->GetPosition() - m_refP2->GetPosition() ); 00099 // spring current length scalar 00100 T scl = cL.Length(); 00101 if ( scl == TAPs::Math<T>::ZERO ) return TAPs::CGMath<T>::ZeroVector; 00102 cL /= scl; // normalize the length vector 00103 // velocity difference of the two particles linked by the spring 00104 Vector3<T> V = ( m_refP1->GetVelocity() - m_refP2->GetVelocity() ); 00105 //----------------------------------------------------------- 00106 // Formula from Physically Based Modeling (Siggraph 2001 Course Note) 00107 // F1 = -{Ks(l - r) + Kd[(V1-V2)*L]/l}*L/l 00108 // F2 = -F1 00109 // where Ks = spring stiffness, Kd = spring damping, 00110 // V1 and V2 are velocity of particles linked by the spring 00111 // r = spring rest length 00112 // L = vector of difference of positions of particle#1 and #2 00113 // l = magnitude of L 00114 //return ( ( m_tK * (scl - m_tL) ) + ( m_tD * V * cL ) ) * cL; 00115 return ( ( m_tK * scl ) + ( m_tD * V * cL ) ) * cL; // since m_tL is zero 00116 } 00117 }
Definition at line 123 of file TAPsSpringRef.cpp.
00124 { 00125 // Not Home Spring 00126 if ( m_iNumHops > 0 ) { 00127 // Local Variables ------------------------------------------ 00128 // spring current length vector 00129 Vector3<T> cL = ( m_refP1->GetPosition() - m_refP2->GetPosition() ); 00130 // spring current length scalar 00131 T scl = cL.Length(); 00132 cL /= scl; // normalize the length vector 00133 // velocity difference of the two particles linked by the spring 00134 Vector3<T> V = ( m_refP1->GetVelocity() - m_refP2->GetVelocity() ); 00135 //----------------------------------------------------------- 00136 // Formula from Physically Based Modeling (Siggraph 2001 Course Note) 00137 // F1 = -{Ks(l - r) + Kd[(V1-V2)*L]/l}*L/l 00138 // F2 = -F1 00139 // where Ks = spring stiffness, Kd = spring damping, 00140 // V1 and V2 are velocity of particles linked by the spring 00141 // r = spring rest length 00142 // L = vector of difference of positions of particle#1 and #2 00143 // l = magnitude of L 00144 return ( ( m_tK * (scl - m_tL) ) + ( m_tD * V * cL ) ) * cL; 00145 } 00146 // Home Spring 00147 else { 00148 // Local Variables ------------------------------------------ 00149 // spring current length vector 00150 Vector3<T> cL = ( m_refP1->GetPosition() - m_refP2->GetPosition() ); 00151 // spring current length scalar 00152 T scl = cL.Length(); 00153 if ( scl == TAPs::Math<T>::ZERO ) return TAPs::CGMath<T>::ZeroVector; 00154 cL /= scl; // normalize the length vector 00155 // velocity difference of the two particles linked by the spring 00156 Vector3<T> V = ( m_refP1->GetVelocity() - m_refP2->GetVelocity() ); 00157 //----------------------------------------------------------- 00158 // Formula from Physically Based Modeling (Siggraph 2001 Course Note) 00159 // F1 = -{Ks(l - r) + Kd[(V1-V2)*L]/l}*L/l 00160 // F2 = -F1 00161 // where Ks = spring stiffness, Kd = spring damping, 00162 // V1 and V2 are velocity of particles linked by the spring 00163 // r = spring rest length 00164 // L = vector of difference of positions of particle#1 and #2 00165 // l = magnitude of L 00166 //return ( ( m_tK * (scl - m_tL) ) + ( m_tD * V * cL ) ) * cL; 00167 return ( ( m_tK * scl ) + ( m_tD * V * cL ) ) * cL; // since m_tL is zero 00168 } 00169 }
| ParticleRef< T > const & SpringRef< T >::GetParticleOne | ( | ) | const [inline] |
| ParticleRef< T > & SpringRef< T >::GetParticleOne | ( | ) | [inline] |
| ParticleRef< T > const & SpringRef< T >::GetParticleTwo | ( | ) | const [inline] |
| ParticleRef< T > & SpringRef< T >::GetParticleTwo | ( | ) | [inline] |
| T SpringRef< T >::GetRestLengthL | ( | ) | const [inline] |
| SpringRef<T> const& SpringRef< T >::operator= | ( | SpringRef< T > const & | S | ) | [inline, private] |
| void SpringRef< T >::SetConstantK | ( | T | Ks | ) | [inline] |
| void SpringRef< T >::SetDampingD | ( | T | Kd | ) | [inline] |
| void SpringRef< T >::SetRestLengthL | ( | T | length | ) | [inline] |
| void SpringRef< T >::SpringsCreation | ( | HEVertexList< T > * | meshVertex, | |
| std::list< int > & | vertexNo, | |||
| std::list< ParticleRef< T > > & | particleList, | |||
| T | mass, | |||
| std::list< SpringRef< T > > & | springNo, | |||
| T | Ks, | |||
| T | Kd, | |||
| int | hopDistance = 1 | |||
| ) | [inline, static] |
Definition at line 265 of file TAPsSpringRef.cpp.
00266 : Mesh XVertex 00267 std::list<int> & vertexNo, // O/P: vertex# associates Mesh XVertex w/ Spring# 00268 std::list< ParticleRef<T> > & particleList, // O/P: Particle List 00269 T mass, // I/P: mass for each particle 00270 std::list< SpringRef<T> > & springNo, // O/P: Spring List 00271 T Ks, T Kd, // I/P: Spring Stiffness and Damping Constant 00272 int hopDistance // I/P: Number of distance/rigidity for spring connection 00273 ) 00274 { 00275 if ( !meshVertex ) return; 00276 //---------------------------------------------------------------- 00277 HEVertex<T> * vertex = meshVertex.Head(); 00278 //---------------------------------------------------------------- 00279 vertexNo.clear(); 00280 for ( int i = 0; i < meshVertex.Size(); ++i ) { 00281 // vertex = 00282 } 00283 //---------------------------------------------------------------- 00284 //---------------------------------------------------------------- 00285 //---------------------------------------------------------------- 00286 }
| static void SpringRef< T >::SpringsCreation | ( | XVertex< T > * | meshVertex, | |
| int * | vertexNo, | |||
| ParticleRef< T > * | particleNo, | |||
| T | mass, | |||
| SpringRef< T > * | springNo, | |||
| T | Ks, | |||
| T | Kd, | |||
| int | hopDistance = 1 | |||
| ) | [static] |
| static void SpringRef< T >::SpringsCreation | ( | Vertex< T > * | meshVertex, | |
| int * | vertexNo, | |||
| ParticleRef< T > * | particleNo, | |||
| T | mass, | |||
| SpringRef< T > * | springNo, | |||
| T | Ks, | |||
| T | Kd, | |||
| int | hopDistance = 1 | |||
| ) | [static] |
| std::ostream& operator<< | ( | std::ostream & | output, | |
| SpringRef< T > const & | S | |||
| ) | [friend] |
Definition at line 23 of file TAPsSpringRef.hpp.
00024 { 00025 output << "Spring<" << typeid(T).name() << "> ==> " 00026 << "\n -------START--SPRING_VERTEX--INFO-------" 00027 << "\n Particle#1: " << *(S.m_refP1) 00028 << "\n Particle#2: " << *(S.m_refP2) 00029 << "\n K Constant: " << S.m_tK 00030 << "\n D Damping: " << S.m_tD 00031 << "\n L Length: " << S.m_tL 00032 << "\n Force#1: " << S.GetForce1() 00033 << "\n Force#2: " << S.GetForce2() 00034 << "\n Current Length: " << S.GetCurrentLength() 00035 << "\n --------END--SPRING_VERTEX--INFO--------\n"; 00036 return output; 00037 }
int SpringRef< T >::m_iNumHops [private] |
Definition at line 47 of file TAPsSpringRef.hpp.
ParticleRef<T>* SpringRef< T >::m_refP1 [private] |
Definition at line 41 of file TAPsSpringRef.hpp.
ParticleRef<T>* SpringRef< T >::m_refP2 [private] |
Definition at line 42 of file TAPsSpringRef.hpp.
Definition at line 44 of file TAPsSpringRef.hpp.
Definition at line 43 of file TAPsSpringRef.hpp.
Definition at line 45 of file TAPsSpringRef.hpp.
1.5.6