1 |
tim |
1232 |
#ifndef _CONSTRAINT_PAIR_H_ |
2 |
|
|
#define _CONSTRAINT_PAIR_H_ |
3 |
|
|
|
4 |
|
|
#include "ConstraintElement.hpp" |
5 |
|
|
|
6 |
|
|
class ConstraintAlgorithm; |
7 |
|
|
class ConstraintPair{ |
8 |
|
|
public: |
9 |
|
|
~ConstraintPair() {} |
10 |
|
|
ConstraintElement* firstElem; |
11 |
|
|
ConstraintElement* secondElem; |
12 |
|
|
|
13 |
|
|
bool isMoved() {return firstElem->getMoved() || secondElem->getMoved();} |
14 |
|
|
virtual double getBondLength2() = 0; |
15 |
|
|
|
16 |
|
|
protected: |
17 |
|
|
ConstraintPair(ConstraintElement* ce1, ConstraintElement* ce2) : firstElem(ce1), secondElem(ce2){} |
18 |
|
|
}; |
19 |
|
|
|
20 |
|
|
|
21 |
|
|
//Constrain two linked rigid bodies which share the same joint |
22 |
|
|
class JointConstraintPair : public ConstraintPair{ |
23 |
|
|
public: |
24 |
|
|
JointConstraintPair(ConstraintElement* ce1, ConstraintElement* ce2) : ConstraintPair(ce1, ce2){} |
25 |
|
|
double getBondLength2() {return 0;} |
26 |
|
|
}; |
27 |
|
|
|
28 |
|
|
//constraint two |
29 |
|
|
class DistanceConstraintPair : public ConstraintPair{ |
30 |
|
|
public: |
31 |
|
|
DistanceConstraintPair(ConstraintElement* ce1, ConstraintElement* ce2, double bondLength2) |
32 |
|
|
: ConstraintPair(ce1, ce2), d2(bondLength2){} |
33 |
|
|
double getBondLength2() {return d2;} |
34 |
|
|
private: |
35 |
|
|
double d2; |
36 |
|
|
}; |
37 |
|
|
|
38 |
|
|
#endif //ifndef _CONSTRAINT_PAIR_H_ |