Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | File List | Namespace Members | Class Members | File Members | Related Pages

rctracker.h

Go to the documentation of this file.
00001 /*
00002     Sheep - A Rigid Body Dynamics Engine
00003     Copyright (C) 2001-2004 Francois Beaune
00004     Contact: http://toxicengine.sourceforge.net/
00005 
00006     This file is part of Sheep.
00007 
00008     Sheep is free software; you can redistribute it and/or modify
00009     it under the terms of the GNU General Public License as published by
00010     the Free Software Foundation; either version 2 of the License, or
00011     (at your option) any later version.
00012 
00013     Sheep is distributed in the hope that it will be useful,
00014     but WITHOUT ANY WARRANTY; without even the implied warranty of
00015     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00016     GNU General Public License for more details.
00017 
00018     You should have received a copy of the GNU General Public License
00019     along with Sheep; if not, write to the Free Software
00020     Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
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>    // std::find(), std::remove_if()
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         // Resting contacts to keep track of. A vector is convenient to store
00051         // a set of resting contacts since they need to be accessed randomly.
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

Generated on Tue May 11 01:31:51 2004 for toxic by doxygen 1.3.6