My Project: dynamics.mod/NewtonDynamics/source/physics/dgBilateralConstraint.h Source File

My Project

dgBilateralConstraint.h
Go to the documentation of this file.
1 /* Copyright (c) <2003-2011> <Julio Jerez, Newton Game Dynamics>
2 *
3 * This software is provided 'as-is', without any express or implied
4 * warranty. In no event will the authors be held liable for any damages
5 * arising from the use of this software.
6 *
7 * Permission is granted to anyone to use this software for any purpose,
8 * including commercial applications, and to alter it and redistribute it
9 * freely, subject to the following restrictions:
10 *
11 * 1. The origin of this software must not be misrepresented; you must not
12 * claim that you wrote the original software. If you use this software
13 * in a product, an acknowledgment in the product documentation would be
14 * appreciated but is not required.
15 *
16 * 2. Altered source versions must be plainly marked as such, and must not be
17 * misrepresented as being the original software.
18 *
19 * 3. This notice may not be removed or altered from any source distribution.
20 */
21
22 #ifndef _DGBILATERALCONSTRAINT_H__
23 #define _DGBILATERALCONSTRAINT_H__
24
25 #include "dgConstraint.h"
26
27 #define DG_BILATERAL_CONTRAINT_DOF 8
28
29 class dgBilateralConstraint: public dgConstraint
30 {
31 public:
32 virtual void SetDestructorCallback (OnConstraintDestroy destructor);
33
34 protected:
35 dgBilateralConstraint ();
36 virtual ~dgBilateralConstraint ();
37
38 virtual void Init (){dgAssert (0);}
39 virtual void Remove (dgWorld* world) {dgAssert (0);}
40 virtual bool IsBilateral () const;
41
42 virtual dgFloat32 GetStiffness() const;
43 virtual void SetStiffness(dgFloat32 stiffness);
44
45 void SetPivotAndPinDir(const dgVector &pivot, const dgVector &pinDirection);
46 void SetPivotAndPinDir (const dgVector& pivot, const dgVector& pinDirection0, const dgVector& pinDirection1);
47 dgVector CalculateGlobalMatrixAndAngle (dgMatrix& globalMatrix0, dgMatrix& globalMatrix1) const;
48 void CalculateMatrixOffset (const dgVector& pivot, const dgVector& dir, dgMatrix& matrix0, dgMatrix& matrix1);
49
50
51 virtual void JointAccelerations(dgJointAccelerationDecriptor* const params);
52 virtual void JointVelocityCorrection(dgJointAccelerationDecriptor* const params);
53
54 void SetMotorAcceleration (dgInt32 index, dgFloat32 accelration, dgContraintDescritor& desc);
55 void SetJacobianDerivative (dgInt32 index, dgContraintDescritor& desc, const dgFloat32* const jacobianA, const dgFloat32* const jacobianB, dgForceImpactPair* const jointForce);
56 void CalculatePointDerivative (dgInt32 index, dgContraintDescritor& desc, const dgVector& normalGlobal, const dgPointParam& param, dgForceImpactPair* const jointForce);
57 void CalculateAngularDerivative (dgInt32 index, dgContraintDescritor& desc, const dgVector& normalGlobal, dgFloat32 stiffness, dgFloat32 jointAngle, dgForceImpactPair* const jointForce);
58 dgFloat32 CalculateSpringDamperAcceleration (dgInt32 index, const dgContraintDescritor& desc, dgFloat32 jointAngle, const dgVector& p0Global, const dgVector& p1Global, dgFloat32 springK, dgFloat32 springD);
59
60 void SetMaxContactsForExactSolver (bool mode, dgInt32 MaxCount);
61
62 dgMatrix m_localMatrix0;
63 dgMatrix m_localMatrix1;
64 dgFloat32 m_stiffness;
65 dgForceImpactPair m_jointForce[DG_BILATERAL_CONTRAINT_DOF];
66 dgInt32 m_rowIsMotor[DG_BILATERAL_CONTRAINT_DOF];
67 dgFloat32 m_motorAcceleration[DG_BILATERAL_CONTRAINT_DOF];
68 dgInt32 m_useExactSolverContactLimit;
69
70 OnConstraintDestroy m_destructor;
71
72 friend class dgWorldDynamicUpdate;
73 };
74
75 #endif
76
dgBilateralConstraint::m_destructor
OnConstraintDestroy m_destructor
Definition: dgBilateralConstraint.h:70
dgForceImpactPair
Definition: dgConstraint.h:73
dgAssert
#define dgAssert(x)
Definition: dgTypes.h:158
dgFloat32
float dgFloat32
Definition: dgTypes.h:233
dgInt32
int dgInt32
Definition: dgTypes.h:218
dgBilateralConstraint::SetPivotAndPinDir
void SetPivotAndPinDir(const dgVector &pivot, const dgVector &pinDirection)
Definition: dgBilateralConstraint.cpp:125
DG_BILATERAL_CONTRAINT_DOF
#define DG_BILATERAL_CONTRAINT_DOF
Definition: dgBilateralConstraint.h:27
dgVector
Definition: dgVector.h:639
dgBilateralConstraint::GetStiffness
virtual dgFloat32 GetStiffness() const
Definition: dgBilateralConstraint.cpp:83
dgBilateralConstraint::m_jointForce
dgForceImpactPair m_jointForce[DG_BILATERAL_CONTRAINT_DOF]
Definition: dgBilateralConstraint.h:65
dgBilateralConstraint::m_stiffness
dgFloat32 m_stiffness
Definition: dgBilateralConstraint.h:64
dgBilateralConstraint::~dgBilateralConstraint
virtual ~dgBilateralConstraint()
Definition: dgBilateralConstraint.cpp:63
dgContraintDescritor
Definition: dgConstraint.h:118
dgConstraint.h
dgBilateralConstraint
Definition: dgBilateralConstraint.h:29
dgBilateralConstraint::SetMotorAcceleration
void SetMotorAcceleration(dgInt32 index, dgFloat32 accelration, dgContraintDescritor &desc)
Definition: dgBilateralConstraint.cpp:179
dgWorldDynamicUpdate
Definition: dgWorldDynamicUpdate.h:252
dgJointCallbackParam
Definition: dgConstraint.h:63
dgBilateralConstraint::m_rowIsMotor
dgInt32 m_rowIsMotor[DG_BILATERAL_CONTRAINT_DOF]
Definition: dgBilateralConstraint.h:66
dgBilateralConstraint::CalculateAngularDerivative
void CalculateAngularDerivative(dgInt32 index, dgContraintDescritor &desc, const dgVector &normalGlobal, dgFloat32 stiffness, dgFloat32 jointAngle, dgForceImpactPair *const jointForce)
Definition: dgBilateralConstraint.cpp:260
dgBilateralConstraint::m_localMatrix0
dgMatrix m_localMatrix0
Definition: dgBilateralConstraint.h:62
dgBilateralConstraint::CalculatePointDerivative
void CalculatePointDerivative(dgInt32 index, dgContraintDescritor &desc, const dgVector &normalGlobal, const dgPointParam &param, dgForceImpactPair *const jointForce)
Definition: dgBilateralConstraint.cpp:326
dgBilateralConstraint::CalculateSpringDamperAcceleration
dgFloat32 CalculateSpringDamperAcceleration(dgInt32 index, const dgContraintDescritor &desc, dgFloat32 jointAngle, const dgVector &p0Global, const dgVector &p1Global, dgFloat32 springK, dgFloat32 springD)
Definition: dgBilateralConstraint.cpp:224
OnConstraintDestroy
void(dgApi * OnConstraintDestroy)(dgConstraint &me)
Definition: dgConstraint.h:136
dgBilateralConstraint::m_useExactSolverContactLimit
dgInt32 m_useExactSolverContactLimit
Definition: dgBilateralConstraint.h:68
dgConstraint::dgPointParam
Definition: dgConstraint.h:183
dgBilateralConstraint::IsBilateral
virtual bool IsBilateral() const
Definition: dgBilateralConstraint.cpp:72
dgBilateralConstraint::m_localMatrix1
dgMatrix m_localMatrix1
Definition: dgBilateralConstraint.h:63
dgBilateralConstraint::CalculateMatrixOffset
void CalculateMatrixOffset(const dgVector &pivot, const dgVector &dir, dgMatrix &matrix0, dgMatrix &matrix1)
Definition: dgBilateralConstraint.cpp:101
dgBilateralConstraint::JointVelocityCorrection
virtual void JointVelocityCorrection(dgJointAccelerationDecriptor *const params)
Definition: dgBilateralConstraint.cpp:475
dgBilateralConstraint::SetStiffness
virtual void SetStiffness(dgFloat32 stiffness)
Definition: dgBilateralConstraint.cpp:89
dgBilateralConstraint::CalculateGlobalMatrixAndAngle
dgVector CalculateGlobalMatrixAndAngle(dgMatrix &globalMatrix0, dgMatrix &globalMatrix1) const
Definition: dgBilateralConstraint.cpp:157
dgMatrix
Definition: dgMatrix.h:40
dgBilateralConstraint::SetJacobianDerivative
void SetJacobianDerivative(dgInt32 index, dgContraintDescritor &desc, const dgFloat32 *const jacobianA, const dgFloat32 *const jacobianB, dgForceImpactPair *const jointForce)
Definition: dgBilateralConstraint.cpp:188
dgConstraint
Definition: dgConstraint.h:140
dgBilateralConstraint::SetMaxContactsForExactSolver
void SetMaxContactsForExactSolver(bool mode, dgInt32 MaxCount)
Definition: dgBilateralConstraint.cpp:77
dgWorld
Definition: dgWorld.h:129
dgBilateralConstraint::m_motorAcceleration
dgFloat32 m_motorAcceleration[DG_BILATERAL_CONTRAINT_DOF]
Definition: dgBilateralConstraint.h:67
dgJointAccelerationDecriptor
Definition: dgConstraint.h:106
dgBilateralConstraint::dgBilateralConstraint
dgBilateralConstraint()
Definition: dgBilateralConstraint.cpp:40
dgBilateralConstraint::SetDestructorCallback
virtual void SetDestructorCallback(OnConstraintDestroy destructor)
Definition: dgBilateralConstraint.cpp:96
dgBilateralConstraint::Init
virtual void Init()
Definition: dgBilateralConstraint.h:38
dgBilateralConstraint::Remove
virtual void Remove(dgWorld *world)
Definition: dgBilateralConstraint.h:39
dgBilateralConstraint::JointAccelerations
virtual void JointAccelerations(dgJointAccelerationDecriptor *const params)
Definition: dgBilateralConstraint.cpp:401