MBSim

Project Page
contour_functions.h
1 /* Copyright (C) 2004-2006 Robert Huber
2 
3  * This library is free software; you can redistribute it and/or
4  * modify it under the terms of the GNU Lesser General Public
5  * License as published by the Free Software Foundation; either
6  * version 2.1 of the License, or (at your option) any later version.
7  *
8  * This library is distributed in the hope that it will be useful,
9  * but WITHOUT ANY WARRANTY; without even the implied warranty of
10  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11  * Lesser General Public License for more details.
12  *
13  * You should have received a copy of the GNU Lesser General Public
14  * License along with this library; if not, write to the Free Software
15  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
16 
17  *
18  * Contact:
19  * rzander@users.berlios.de
20  *
21  */
22 #ifndef CONTOUR_FUNCTION_1S_H
23 #define CONTOUR_FUNCTION_1S_H
24 
25 #include "fmatvec.h"
26 #include "mbsim/utils/ppolynom.h"
27 #include "mbsim/contour_pdata.h"
28 
29 namespace MBSim {
30 
31  //================================================================================================================================
35  public:
36  ContourFunction1s() {};
37  virtual ~ContourFunction1s() {};
38  virtual void init(const double& alpha) {};
39  virtual void init(const ContourPointData &cp) { init(cp.getLagrangeParameterPosition()(0)); }
40  virtual fmatvec::Vec operator()(const double& alpha, const void * =NULL) = 0;
41  virtual fmatvec::Vec diff1(const double& alpha) = 0;
42  virtual fmatvec::Vec diff2(const double& alpha) = 0;
43  virtual fmatvec::Vec computeN(const double& alpha) { const fmatvec::Vec N=crossProduct(diff1(alpha),computeB(alpha)); return N/nrm2(N); }
44  virtual fmatvec::Vec computeN(const ContourPointData &cp) { return computeN(cp.getLagrangeParameterPosition()(0)); };
45  virtual fmatvec::Vec computeT(const double& alpha) { const fmatvec::Vec T=-diff1(alpha); return T/nrm2(T); }
46  virtual fmatvec::Vec computeT(const ContourPointData &cp) { return computeT(cp.getLagrangeParameterPosition()(0)); };
47  virtual fmatvec::Vec computeB(const double& alpha) { const fmatvec::Vec B = crossProduct(operator()(alpha), diff1(alpha)); return B/nrm2(B); }
48  virtual fmatvec::Vec computeB(const ContourPointData &cp) { return computeB(cp.getLagrangeParameterPosition()(0)); };
49  virtual double computeCurvature(const double& alpha) {
50  const fmatvec::Vec rs = diff1(alpha);
51  const double nrm2rs = nrm2(rs);
52  return nrm2(crossProduct(rs,diff2(alpha)))/(nrm2rs*nrm2rs*nrm2rs);
53  }
54  virtual double computeCurvature(const ContourPointData &cp) {return computeCurvature(cp.getLagrangeParameterPosition()(0)); }
55 
56  virtual double computeR(const double &alpha) {return 0; }
57  virtual double computedRdAlpha(const double &alpha) {return 0; }
58  virtual double computed2RdAlpha2(const double &alpha) {return 0; }
59 
60  double getalphaStart() { return alphaStart; }
61  double getalphaEnd() { return alphaEnd; }
62  void setalphaStart(double alphaStart_) { alphaStart = alphaStart_; };
63  void setalphaEnd(double alphaEnd_) { alphaEnd = alphaEnd_; };
64 
65  virtual void initializeUsingXML(TiXmlElement * element) {};
66 
67  protected:
68  double alphaStart, alphaEnd;
69  };
70 }
71 
72 #endif
73