00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020 #ifndef _GEAR_H_
00021 #define _GEAR_H_
00022
00023 #include "mbsim/link_mechanics.h"
00024 #include "mbsim/rigid_body.h"
00025
00026 namespace MBSim {
00027
00028 class Gear : public LinkMechanics {
00029 protected:
00030 Function2<double,double,double> *func;
00031 std::vector<RigidBody*> body;
00032 std::vector<double> ratio;
00033 std::vector<Frame> C;
00034 public:
00035 Gear(const std::string &name);
00036 void updateh(double, int i=0);
00037 void updateW(double, int i=0);
00038 void updateg(double);
00039 void updategd(double);
00040 void updateJacobians(double t, int j=0);
00041 void updatewb(double t, int i=0);
00042 void updatehRef(const fmatvec::Vec &hParent, int j=0);
00043 void updateWRef(const fmatvec::Mat &WParent, int j=0);
00044 void setDependentBody(RigidBody* body_) {body[0] = body_;}
00045 void addDependency(RigidBody* body_, double ratio);
00046
00047 bool isActive() const { return true; }
00048 bool gActiveChanged() { return false; }
00049 std::string getType() const { return "Gear"; }
00050 void init(InitStage stage);
00051 bool isSetValued() const;
00052 virtual void calclaSize(int j);
00053 virtual void calcgSize(int j);
00054 virtual void calcgdSize(int j);
00055
00056 void setForceFunction(Function2<double,double,double> *func_) { func=func_; }
00057
00058 void plot(double t, double dt=1);
00059
00060 #ifdef HAVE_OPENMBVCPPINTERFACE
00061
00062 void setOpenMBVForceArrow(OpenMBV::Arrow *arrow) { FArrow[0] = arrow; }
00063
00065 void setOpenMBVMomentArrow(OpenMBV::Arrow *arrow) { MArrow[0] = arrow; }
00066 #endif
00067
00068 protected:
00069 #ifdef HAVE_OPENMBVCPPINTERFACE
00070 std::vector<OpenMBV::Arrow*> FArrow, MArrow;
00071 #endif
00072
00073 };
00074
00075 }
00076
00077 #endif