MBSim

Project Page
gear.h
00001 /* Copyright (C) 2004-2011 MBSim Development Team
00002  *
00003  * This library is free software; you can redistribute it and/or 
00004  * modify it under the terms of the GNU Lesser General Public 
00005  * License as published by the Free Software Foundation; either 
00006  * version 2.1 of the License, or (at your option) any later version. 
00007  *  
00008  * This library is distributed in the hope that it will be useful, 
00009  * but WITHOUT ANY WARRANTY; without even the implied warranty of 
00010  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU 
00011  * Lesser General Public License for more details. 
00012  *  
00013  * You should have received a copy of the GNU Lesser General Public 
00014  * License along with this library; if not, write to the Free Software 
00015  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301 USA
00016  *
00017  * Contact: martin.o.foerg@gmail.com
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