All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Pages
polynomial_frustum.h
1 /* Copyright (C) 2004-2012 MBSim Development Team
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  * Contact: martin.o.foerg@googlemail.com
18  */
19 
20 #ifndef POLYNOMIAL_FRUSTUM_H_
21 #define POLYNOMIAL_FRUSTUM_H_
22 #include <iostream>
23 #include <mbsim/contours/contour.h>
24 #include <mbsim/contours/plate.h>
25 #include <mbsim/utils/colors.h>
26 #include <fmatvec/fmatvec.h>
27 #include <mbsim/functions/function.h>
28 #include <mbsim/utils/boost_parameters.h>
29 
30 namespace MBSim {
31 
39  public:
45  PolynomialFrustum(const std::string & name, const fmatvec::Vec & param_);
46 
50  virtual ~PolynomialFrustum() { }
51 
52  /* INHERITED INTERFACE OF ELEMENT */
53  std::string getType() const { return "PolynomialFrustum"; }
54  virtual void init(InitStage stage);
55  /***************************************************/
56 
57  /* INHERITED INTERFACE OF CONTOUR*/
63  virtual fmatvec::Vec2 evalZeta(const fmatvec::Vec3 &WrPS);
64  /*********************************/
65 
70  void setHeight(const double & height_) { height = height_; }
71 
75  double getHeight() { return height; }
76 
80  double getHeight() const { return height; }
81 
88  BOOST_PARAMETER_MEMBER_FUNCTION( (void), enableOpenMBV, tag, (optional (polynomialPoints,(int),0)(circularPoints,(int),25)(diffuseColor,(const fmatvec::Vec3&),"[-1;1;1]")(transparency,(double),0))) { enableOpenMBV_(diffuseColor,transparency,polynomialPoints,circularPoints); }
89 
93  void setColor(const MBSim::RGBColor & color);
94 
98  void setTransparency(const double & transparency);
99 
103  double evalValue(const double & x);
104 
108  double evalValue(const double & x) const;
109 
113  double evalValueD1(const double & x);
114 
118  double evalValueD1(const double & x) const;
119 
123  double evalValueD2(const double & x);
124 
128  double evalValueD2(const double & x) const;
129 
133  double getXPolyMax();
134 
139  double getEnclosingSphereRadius();
140 
144  fmatvec::Vec3 getEnclosingSphereCenter();
145 
150 
154  fmatvec::Vec3 evalKrPS(const fmatvec::Vec2 &zeta);
155 
159  fmatvec::Vec3 evalKn(const fmatvec::Vec2 &zeta);
160 
164  fmatvec::Vec3 evalKu(const fmatvec::Vec2 &zeta);
165 
169  fmatvec::Vec3 evalKv(const fmatvec::Vec2 &zeta);
170 
171 // /*!
172 // * \brief in 2D plane, given a point outside a polynomial curve, search for the closest point on the curve to the point
173 // * \param x_0: starting point of the polynomial domain
174 // * \param x_end: end point of the polynomial domain
175 // * \param P: the given point
176 // * \return: a dimension 3 vector, vec[0] storing the dis, vec[1] and vec[2] for the 2D position of the closest point on the curve
177 // */
178 // fmatvec::Vec3 CP_toP_onPolycurve2D(double x_0, double x_end, fmatvec::Vec2 P);
179 
180  fmatvec::Vec3 evalWn(const fmatvec::Vec2 &zeta);
181  fmatvec::Vec3 evalWu(const fmatvec::Vec2 &zeta);
182  fmatvec::Vec3 evalWv(const fmatvec::Vec2 &zeta);
183 
184  protected:
188  void updateEnclosingSphere();
189 
195 
199  double height;
200 
204  double sphereRadius;
205 
210 
214  double transparency;
215 
220 
225 
229  void createInventorFile();
230 
231  void enableOpenMBV_(const fmatvec::Vec3 &dc, double tp, int polynomialPoints, int circularPoints);
232  };
233 
239  class ContactPolyfun : public Function<double(double)> {
240  public:
244  ContactPolyfun(const double & rhs, const PolynomialFrustum * frustum);
245  virtual ~ContactPolyfun() {
246  }
247 
248  virtual double operator()(const double &x);
249  void initializeUsingXML() {
250  }
251 
252  protected:
253  double rhs;
254  const PolynomialFrustum * frustum;
255 
256  };
257 
258 }
259 
260 #endif /* POLYNOMIAL_FRUSTUM_H_ */
fmatvec::Vec3 evalWu(const fmatvec::Vec2 &zeta)
Definition: polynomial_frustum.cc:237
fmatvec::Vec3 evalKu(const fmatvec::Vec2 &zeta)
returns the tangent in radial direction in local coordinates of the frustum at the position (x...
Definition: polynomial_frustum.cc:194
basic class for rigid contours
Definition: rigid_contour.h:37
MBSim::RGBColor color
color values for the iv-body
Definition: polynomial_frustum.h:209
double transparency
transparency value for the body
Definition: polynomial_frustum.h:214
fmatvec::Vec3 getEnclosingSphereCenter()
return the center of the enclosing sphere
Definition: polynomial_frustum.cc:163
PolynomialFrustum(const std::string &name, const fmatvec::Vec &param_)
Constructor.
Definition: polynomial_frustum.cc:33
void updateEnclosingSphere()
Definition: polynomial_frustum.cc:216
double evalValueD2(const double &x)
get value at position of second derivative
Definition: polynomial_frustum.cc:133
void setHeight(const double &height_)
set height of frustum
Definition: polynomial_frustum.h:70
double height
height of the frustum
Definition: polynomial_frustum.h:199
fmatvec::Vec3 evalWn(const fmatvec::Vec2 &zeta)
in 2D plane, given a point outside a polynomial curve, search for the closest point on the curve to t...
Definition: polynomial_frustum.cc:233
double sphereRadius
radius of the enclosing sphere
Definition: polynomial_frustum.h:204
double getEnclosingSphereRadius()
take the largest one among the distance from ((a+b)/2,0) to (a,f(a)),(b,f(b)) and (x...
Definition: polynomial_frustum.cc:159
double getXPolyMax()
get inner peak value of the polynomial
Definition: polynomial_frustum.cc:149
virtual void init(InitStage stage)
plots time series header
Definition: polynomial_frustum.cc:40
fmatvec::Vec3 evalWv(const fmatvec::Vec2 &zeta)
Definition: polynomial_frustum.cc:241
Frustum contour with a polynomial radius over height course.
Definition: polynomial_frustum.h:38
fmatvec::Vec3 evalKrPS(const fmatvec::Vec2 &zeta)
returns the point in local coordinates of the frustum at the position (x, phi)
Definition: polynomial_frustum.cc:173
virtual ~PolynomialFrustum()
Destructor.
Definition: polynomial_frustum.h:50
InitStage
The stages of the initialization.
Definition: element.h:97
const fmatvec::Vec & getPolynomialParameters()
get coefficient vector of the polynomial
Definition: polynomial_frustum.cc:169
Definition: planar_contour.h:31
std::string name
name of element
Definition: element.h:298
double evalValueD1(const double &x)
get value at position of first derivative
Definition: polynomial_frustum.cc:117
fmatvec::Vec parameters
vector holding our parameters of the polynom describing the frustum (radius over height) parameters=[...
Definition: polynomial_frustum.h:194
double getHeight() const
return height of frustum
Definition: polynomial_frustum.h:80
fmatvec::Vec3 evalKn(const fmatvec::Vec2 &zeta)
returns the normal in local coordinates of the frustum at the position (x, phi)
Definition: polynomial_frustum.cc:183
void createInventorFile()
create inventor file for visualisation
Definition: polynomial_frustum.cc:245
BOOST_PARAMETER_MEMBER_FUNCTION((void), enableOpenMBV, tag,(optional(polynomialPoints,(int), 0)(circularPoints,(int), 25)(diffuseColor,(const fmatvec::Vec3 &),"[-1;1;1]")(transparency,(double), 0)))
enable visualisation
Definition: polynomial_frustum.h:88
this class denotes polynomial equation like this:a0+a1*x+a2*x^2+...+an*x^n=rhs
Definition: polynomial_frustum.h:239
void setColor(const MBSim::RGBColor &color)
set color of body
Definition: polynomial_frustum.cc:93
virtual fmatvec::Vec2 evalZeta(const fmatvec::Vec3 &WrPS)
returns the two lagrange parameters index 0: x, height coordinate of frustum index 1: phi...
Definition: polynomial_frustum.cc:65
void setTransparency(const double &transparency)
set transparency of body
Definition: polynomial_frustum.cc:97
defines additive color using values for each color between [0,1]
Definition: colors.h:33
double evalValue(const double &x)
get value at position of 0 derivative
Definition: polynomial_frustum.cc:101
int polynomialPoints
grid points in polynomial direction
Definition: polynomial_frustum.h:219
ContactPolyfun(const double &rhs, const PolynomialFrustum *frustum)
Constructor.
Definition: polynomial_frustum.cc:368
int circularPoints
grid points in polynomial direction
Definition: polynomial_frustum.h:224
double getHeight()
return height of frustum
Definition: polynomial_frustum.h:75
std::string getType() const
Definition: polynomial_frustum.h:53
fmatvec::Vec3 evalKv(const fmatvec::Vec2 &zeta)
returns the tangent in azimuthal direction in local coordinates of the frustum at the point x...
Definition: polynomial_frustum.cc:205

Impressum / Disclaimer / Datenschutz Generated by doxygen 1.8.5 Valid HTML