mbsim 4.0.0 MBSim Kernel

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
38 class PolynomialFrustum : public MBSim::RigidContour {
39 public:
45 PolynomialFrustum(const std::string & name, const fmatvec::Vec & param_);
46
50 ~PolynomialFrustum() override = default;
51
52 /* INHERITED INTERFACE OF ELEMENT */
53 void init(InitStage stage, const InitConfigSet &config) override;
54 /***************************************************/
55
56 /* INHERITED INTERFACE OF CONTOUR*/
62 fmatvec::Vec2 evalZeta(const fmatvec::Vec3 &WrPoint) override;
63 /*********************************/
64
69 void setHeight(const double & height_) { height = height_; }
70
74 double getHeight() { return height; }
75
79 double getHeight() const { return height; }
80
87 BOOST_PARAMETER_MEMBER_FUNCTION( (void), enableOpenMBV, tag, (optional (polynomialPoints,(int),0)(circularPoints,(int),25)(diffuseColor,(const fmatvec::Vec3&),fmatvec::Vec3(std::vector<double>{-1,1,1}))(transparency,(double),0)(pointSize,(double),0)(lineWidth,(double),0))) { enableOpenMBV_(diffuseColor,transparency,polynomialPoints,circularPoints); }
88
92 void setColor(const MBSim::RGBColor & color_);
93
97 void setTransparency(const double & transparency_);
98
102 double evalValue(const double & x);
103
107 double evalValue(const double & x) const;
108
112 double evalValueD1(const double & x);
113
117 double evalValueD1(const double & x) const;
118
122 double evalValueD2(const double & x);
123
127 double evalValueD2(const double & x) const;
128
132 double getXPolyMax();
133
138 double getEnclosingSphereRadius();
139
143 fmatvec::Vec3 getEnclosingSphereCenter();
144
148 const fmatvec::Vec & getPolynomialParameters();
149
153 fmatvec::Vec3 evalKrPS(const fmatvec::Vec2 &zeta) override;
154
158 fmatvec::Vec3 evalKn(const fmatvec::Vec2 &zeta) override;
159
163 fmatvec::Vec3 evalKu(const fmatvec::Vec2 &zeta) override;
164
168 fmatvec::Vec3 evalKv(const fmatvec::Vec2 &zeta) override;
169
170 // /*!
171 // * \brief in 2D plane, given a point outside a polynomial curve, search for the closest point on the curve to the point
172 // * \param x_0: starting point of the polynomial domain
173 // * \param x_end: end point of the polynomial domain
174 // * \param P: the given point
175 // * \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
176 // */
177 // fmatvec::Vec3 CP_toP_onPolycurve2D(double x_0, double x_end, fmatvec::Vec2 P);
178
179 fmatvec::Vec3 evalWn(const fmatvec::Vec2 &zeta) override;
180 fmatvec::Vec3 evalWu(const fmatvec::Vec2 &zeta) override;
181 fmatvec::Vec3 evalWv(const fmatvec::Vec2 &zeta) override;
182
183 protected:
187 void updateEnclosingSphere();
188
193 fmatvec::Vec parameters;
194
198 double height;
199
203 double sphereRadius;
204
208 MBSim::RGBColor color;
209
213 double transparency;
214
218 int polynomialPoints;
219
223 int circularPoints;
224
228 void createInventorFile();
229
230 void enableOpenMBV_(const fmatvec::Vec3 &dc, double tp, int polynomialPoints_, int circularPoints_);
231 };
232
238 class ContactPolyfun : public Function<double(double)> {
239 public:
243 ContactPolyfun(const double & rhs, const PolynomialFrustum * frustum);
244 ~ContactPolyfun() override = default;
245
246 double operator()(const double &x) override;
247 void initializeUsingXML(xercesc::DOMElement *) {
248 }
249
250 protected:
251 double rhs;
252 const PolynomialFrustum * frustum;
253
254 };
255
256 }
257
258 #endif /* POLYNOMIAL_FRUSTUM_H_ */
MBSim::PolynomialFrustum::evalKn
fmatvec::Vec3 evalKn(const fmatvec::Vec2 &zeta) override
returns the normal in local coordinates of the frustum at the position (x, phi)
Definition: polynomial_frustum.cc:176
MBSim::PolynomialFrustum::evalWv
fmatvec::Vec3 evalWv(const fmatvec::Vec2 &zeta) override
Definition: polynomial_frustum.cc:234
MBSim::RigidContour
basic class for rigid contours
Definition: rigid_contour.h:37
MBSim::PolynomialFrustum::color
MBSim::RGBColor color
color values for the iv-body
Definition: polynomial_frustum.h:208
MBSim::PolynomialFrustum::getHeight
double getHeight() const
return height of frustum
Definition: polynomial_frustum.h:79
MBSim::PolynomialFrustum::transparency
double transparency
transparency value for the body
Definition: polynomial_frustum.h:213
MBSim::PolynomialFrustum::getEnclosingSphereCenter
fmatvec::Vec3 getEnclosingSphereCenter()
return the center of the enclosing sphere
Definition: polynomial_frustum.cc:156
MBSim::PolynomialFrustum::PolynomialFrustum
PolynomialFrustum(const std::string &name, const fmatvec::Vec &param_)
Constructor.
Definition: polynomial_frustum.cc:34
MBSim::PolynomialFrustum::updateEnclosingSphere
void updateEnclosingSphere()
Definition: polynomial_frustum.cc:209
MBSim::PolynomialFrustum::evalValueD2
double evalValueD2(const double &x)
get value at position of second derivative
Definition: polynomial_frustum.cc:126
MBSim::PolynomialFrustum::setHeight
void setHeight(const double &height_)
set height of frustum
Definition: polynomial_frustum.h:69
MBSim::PolynomialFrustum::height
double height
height of the frustum
Definition: polynomial_frustum.h:198
MBSim::PolynomialFrustum::evalKu
fmatvec::Vec3 evalKu(const fmatvec::Vec2 &zeta) override
returns the tangent in radial direction in local coordinates of the frustum at the position (x,...
Definition: polynomial_frustum.cc:187
MBSim::PolynomialFrustum::sphereRadius
double sphereRadius
radius of the enclosing sphere
Definition: polynomial_frustum.h:203
MBSim::PolynomialFrustum::getEnclosingSphereRadius
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:152
MBSim::PolynomialFrustum::getXPolyMax
double getXPolyMax()
get inner peak value of the polynomial
Definition: polynomial_frustum.cc:142
MBSim::PolynomialFrustum
Frustum contour with a polynomial radius over height course.
Definition: polynomial_frustum.h:38
MBSim::PolynomialFrustum::setColor
void setColor(const MBSim::RGBColor &color_)
set color of body
Definition: polynomial_frustum.cc:86
MBSim::PolynomialFrustum::evalKv
fmatvec::Vec3 evalKv(const fmatvec::Vec2 &zeta) override
returns the tangent in azimuthal direction in local coordinates of the frustum at the point x,...
Definition: polynomial_frustum.cc:198
MBSim::PolynomialFrustum::evalWu
fmatvec::Vec3 evalWu(const fmatvec::Vec2 &zeta) override
Definition: polynomial_frustum.cc:230
MBSim::Element::InitStage
InitStage
The stages of the initialization.
Definition: element.h:62
MBSim::PolynomialFrustum::getPolynomialParameters
const fmatvec::Vec & getPolynomialParameters()
get coefficient vector of the polynomial
Definition: polynomial_frustum.cc:162
MBSim::PolynomialFrustum::~PolynomialFrustum
~PolynomialFrustum() override=default
Destructor.
MBSim::Function
Definition: contact_kinematics.h:32
MBSim::PolynomialFrustum::BOOST_PARAMETER_MEMBER_FUNCTION
BOOST_PARAMETER_MEMBER_FUNCTION((void), enableOpenMBV, tag,(optional(polynomialPoints,(int), 0)(circularPoints,(int), 25)(diffuseColor,(const fmatvec::Vec3 &), fmatvec::Vec3(std::vector< double >{-1, 1, 1}))(transparency,(double), 0)(pointSize,(double), 0)(lineWidth,(double), 0)))
enable visualisation
Definition: polynomial_frustum.h:87
MBSim::Element::name
std::string name
name of element
Definition: element.h:260
MBSim::PolynomialFrustum::evalValueD1
double evalValueD1(const double &x)
get value at position of first derivative
Definition: polynomial_frustum.cc:110
MBSim::PolynomialFrustum::parameters
fmatvec::Vec parameters
vector holding our parameters of the polynom describing the frustum (radius over height) parameters=[...
Definition: polynomial_frustum.h:193
MBSim::PolynomialFrustum::init
void init(InitStage stage, const InitConfigSet &config) override
plots time series header
Definition: polynomial_frustum.cc:41
MBSim::PolynomialFrustum::createInventorFile
void createInventorFile()
create inventor file for visualisation
Definition: polynomial_frustum.cc:238
MBSim::PolynomialFrustum::evalKrPS
fmatvec::Vec3 evalKrPS(const fmatvec::Vec2 &zeta) override
returns the point in local coordinates of the frustum at the position (x, phi)
Definition: polynomial_frustum.cc:166
MBSim::ContactPolyfun
this class denotes polynomial equation like this:a0+a1*x+a2*x^2+...+an*x^n=rhs
Definition: polynomial_frustum.h:238
MBSim::PolynomialFrustum::evalZeta
fmatvec::Vec2 evalZeta(const fmatvec::Vec3 &WrPoint) override
returns the two lagrange parameters index 0: x, height coordinate of frustum index 1: phi,...
Definition: polynomial_frustum.cc:58
MBSim::RGBColor
defines additive color using values for each color between [0,1]
Definition: colors.h:33
MBSim::PolynomialFrustum::evalValue
double evalValue(const double &x)
get value at position of 0 derivative
Definition: polynomial_frustum.cc:94
MBSim::PolynomialFrustum::polynomialPoints
int polynomialPoints
grid points in polynomial direction
Definition: polynomial_frustum.h:218
MBSim::ContactPolyfun::ContactPolyfun
ContactPolyfun(const double &rhs, const PolynomialFrustum *frustum)
Constructor.
Definition: polynomial_frustum.cc:361
MBSim::PolynomialFrustum::setTransparency
void setTransparency(const double &transparency_)
set transparency of body
Definition: polynomial_frustum.cc:90
MBSim::PolynomialFrustum::circularPoints
int circularPoints
grid points in polynomial direction
Definition: polynomial_frustum.h:223
MBSim::PolynomialFrustum::getHeight
double getHeight()
return height of frustum
Definition: polynomial_frustum.h:74
MBSim::PolynomialFrustum::evalWn
fmatvec::Vec3 evalWn(const fmatvec::Vec2 &zeta) override
in 2D plane, given a point outside a polynomial curve, search for the closest point on the curve to t...
Definition: polynomial_frustum.cc:226
MBSim
namespace MBSim
Definition: bilateral_constraint.cc:30