00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023 #ifndef SHEEP_DYNAMICS_RCTRACKER_H
00024 #define SHEEP_DYNAMICS_RCTRACKER_H
00025
00026 #include "common/math/matrix.h"
00027 #include "common/math/real.h"
00028 #include "common/math/vector.h"
00029 #include "common/math/vector3.h"
00030 #include "contact.h"
00031
00032 #include <algorithm>
00033 #include <cassert>
00034 #include <list>
00035 #include <vector>
00036
00037 namespace sheep {
00038
00039 class RCTracker {
00040 public:
00041 inline void Reset();
00042
00043 inline void Insert(Contact &c);
00044
00045 void ResolveAll();
00046
00047 inline ContactVector &GetRestingContacts();
00048
00049 private:
00050
00051
00052 ContactVector m_resting_contacts;
00053
00054 Matrix compute_A_matrix();
00055 Vector compute_b_vector();
00056
00057 class index_set : public std::list<int> {
00058 public:
00059 bool Contains(int i) const {
00060 return std::find(begin(), end(), i) != end();
00061 }
00062 };
00063
00064 index_set C, NC;
00065
00066 Vector fdirection(const Matrix &A, int d);
00067
00068 void maxstep(const Vector &a,
00069 const Vector &f,
00070 const Vector &delta_a,
00071 const Vector &delta_f,
00072 int d, Real *s, int *j);
00073
00074 void drive_to_zero(const Matrix &A, Vector &f, Vector &a, int d);
00075
00076 Vector compute_forces(const Matrix &A, const Vector &b);
00077
00078 struct is_inactivated_rc {
00079 bool operator()(Contact &c) const;
00080 };
00081
00082 void remove_inactivated_rc();
00083 };
00084
00085 #include "rctracker.inl"
00086
00087 }
00088
00089 #endif // !SHEEP_DYNAMICS_RCTRACKER_H