MBSim

Project Page
contour_functions.h
00001 /* Copyright (C) 2004-2006  Robert Huber
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  *
00018  * Contact:
00019  *   rzander@users.berlios.de
00020  *
00021  */
00022 #ifndef CONTOUR_FUNCTION_1S_H
00023 #define CONTOUR_FUNCTION_1S_H
00024 
00025 #include "fmatvec/fmatvec.h"
00026 #include "mbsim/utils/ppolynom.h"
00027 #include "mbsim/contour_pdata.h"
00028 
00029 namespace MBSim {
00030 
00031   //================================================================================================================================
00034   class  ContourFunction1s {
00035     public:
00036       ContourFunction1s() {};
00037       virtual ~ContourFunction1s() {};
00038       virtual void init(const double& alpha) {};
00039       virtual void init(const ContourPointData &cp) { init(cp.getLagrangeParameterPosition()(0)); }
00040       virtual fmatvec::Vec3 operator()(const double& alpha, const void * =NULL) = 0;
00041       virtual fmatvec::Vec3 diff1(const double& alpha) = 0;
00042       virtual fmatvec::Vec3 diff2(const double& alpha) = 0;
00043       virtual fmatvec::Vec3 computeN(const double& alpha) { const fmatvec::Vec3 N=crossProduct(diff1(alpha),computeB(alpha)); return N/nrm2(N); }
00044       virtual fmatvec::Vec3 computeN(const ContourPointData &cp) { return computeN(cp.getLagrangeParameterPosition()(0)); };
00045       virtual fmatvec::Vec3 computeT(const double& alpha) { const fmatvec::Vec3 T=-diff1(alpha); return T/nrm2(T); }
00046       virtual fmatvec::Vec3 computeT(const ContourPointData &cp) { return computeT(cp.getLagrangeParameterPosition()(0)); };
00047       virtual fmatvec::Vec3 computeB(const double& alpha) { const fmatvec::Vec3 B = crossProduct(operator()(alpha), diff1(alpha)); return B/nrm2(B); }
00048       virtual fmatvec::Vec3 computeB(const ContourPointData &cp) { return computeB(cp.getLagrangeParameterPosition()(0)); };
00049       virtual double computeCurvature(const double& alpha) {
00050         const fmatvec::Vec3 rs = diff1(alpha);
00051         const double nrm2rs = nrm2(rs);
00052         return nrm2(crossProduct(rs,diff2(alpha)))/(nrm2rs*nrm2rs*nrm2rs); 
00053       }
00054       virtual double computeCurvature(const ContourPointData &cp) {return computeCurvature(cp.getLagrangeParameterPosition()(0)); }
00055       
00056       virtual double computeR(const double &alpha) {return 0; }
00057       virtual double computedRdAlpha(const double &alpha) {return 0; }
00058       virtual double computed2RdAlpha2(const double &alpha) {return 0; }
00059       
00060       double getalphaStart() { return alphaStart; }
00061       double getalphaEnd() { return alphaEnd; }
00062       void setalphaStart(double alphaStart_) { alphaStart = alphaStart_; }
00063       void setalphaEnd(double alphaEnd_) { alphaEnd = alphaEnd_; }
00064 
00065       virtual void initializeUsingXML(MBXMLUtils::TiXmlElement * element) {}
00066       virtual MBXMLUtils::TiXmlElement* writeXMLFile(MBXMLUtils::TiXmlNode *element) {return 0;}
00067 
00068     protected:
00069       double alphaStart, alphaEnd;
00070   };  
00071 }
00072 
00073 #endif
00074