MBSim

Project Page
contact_kinematics.h
00001 /* Copyright (C) 2004-2009 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@googlemail.com
00018  */
00019 
00020 #ifndef _CONTACT_KINEMATICS_H_
00021 #define _CONTACT_KINEMATICS_H_
00022 
00023 #include "fmatvec/fmatvec.h"
00024 #include "mbsim/mbsim_event.h"
00025 #include <mbsim/single_contact.h>
00026 #include <vector>
00027 
00028 namespace MBSim {
00029 
00030   class Contour;
00031   class ContourPointData;
00032 
00037   fmatvec::Vec3 computeTangential(const fmatvec::Vec3 &n);
00038 
00046   class ContactKinematics {
00047     public:
00051       ContactKinematics() : numberOfPotentialContactPoints(1) {}
00052 
00056       virtual ~ContactKinematics() {}
00057 
00058       /* INTERFACE FOR DERIVED CLASSES */
00063       virtual void assignContours(const std::vector<Contour*> &contour) = 0;
00064 
00071       virtual void updateg(fmatvec::Vec &g, ContourPointData *cpData, int index = 0) = 0;
00072 
00079       virtual void updatewb(fmatvec::Vec &wb, const fmatvec::Vec &g, ContourPointData* cpData) = 0;
00080       
00087       virtual void updateg(std::vector<SingleContact> & contact) {if(contact[0].getg().size()) updateg(contact[0].getg(), contact[0].getcpData());}
00088 
00089       virtual void updatewb(std::vector<SingleContact> & contact) {if(contact[0].getwb().size()) updatewb(contact[0].getwb(), contact[0].getg(), contact[0].getcpData());}
00090 
00096       void assignContours(Contour *contour1, Contour *contour2) { std::vector<Contour*> c; c.push_back(contour1);c.push_back(contour2); assignContours(c); }
00097 
00101       int getNumberOfPotentialContactPoints() const { return numberOfPotentialContactPoints; }
00102 
00103       virtual ContactKinematics* getContactKinematics(int i=0) const { return 0; }
00104 
00108 //      virtual void computeCurvatures(std::vector<fmatvec::Vec>::iterator ir, std::vector<ContourPointData*>::iterator icpData) { if((*ir).size()) computeRadii(*ir, *icpData); }
00109       virtual void computeCurvatures(fmatvec::Vec &r, ContourPointData *cpData) {throw MBSimError("ERROR (ContactKinematics::computeCurvatures): Not implemented.");}
00110 
00111     protected:
00115       int numberOfPotentialContactPoints;
00116   };
00117 
00118 }
00119 
00120 #endif /* _CONTACT_KINEMATICS_H_ */
00121