MBSim

Project Page
rectangle.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 _RECTANGLE_H_
00021 #define _RECTANGLE_H_
00022 
00023 #include "mbsim/contours/plane.h"
00024 #include "fmatvec/fmatvec.h"
00025 #include "fmatvec/linear_algebra_double.h"
00026 #include "fmatvec/linear_algebra.h"
00027 
00028 #ifdef HAVE_OPENMBVCPPINTERFACE
00029 #include <mbsim/utils/openmbv_utils.h>
00030 #endif
00031 
00032 namespace MBSim {
00033 
00039   class Rectangle : public Plane {
00040     public:
00045       Rectangle(const std::string &name="", Frame *R=0);
00046 
00047       Rectangle(const std::string &name, double yL, double zL, Frame *R=0);
00048 
00049       Rectangle(const std::string &name, double yL, double zL, double t, Frame *R=0);
00050 
00051       /* INHERITED INTERFACE OF ELEMENT */
00052       std::string getType() const {
00053         return "Rectangle";
00054       }
00055       virtual void init(InitStage stage);
00056       /**********************************/
00057 
00058       /* GETTER / SETTER */
00059       void setYLength(double l) {
00060         yLength = l;
00061       }
00062       void setZLength(double l) {
00063         zLength = l;
00064       }
00065       void setThickness(double thickness_) {thickness = thickness_;}
00066 
00067       double getYLength() const {
00068         return yLength;
00069       }
00070       double getZLength() const {
00071         return zLength;
00072       }
00073       //get vertex of the rectangle, under reference frame of the rectangle
00074       const fmatvec::Vec3 & getA() const {
00075         return RrA;
00076       }
00077       const fmatvec::Vec3 & getB() const {
00078         return RrB;
00079       }
00080       const fmatvec::Vec3 & getC() const {
00081         return RrC;
00082       }
00083       const fmatvec::Vec3 & getD() const {
00084         return RrD;
00085       }
00086       double getThickness() const {return thickness;}
00087 
00088       /***************************************************//*new added part by ting 05.10.2012*/
00095       bool PointInRectangle(const fmatvec::Vec3& Point); //need to be check again.......................................................
00096 
00104       bool PointInCircle(const fmatvec::Vec3& Point, const fmatvec::Vec3& CenCir, const double & radius);
00105 
00110       fmatvec::Vec3 Point_closest_toCircle_onLineseg(const fmatvec::Vec3& EndP1, const fmatvec::Vec3& EndP2, const fmatvec::Vec3& CenCir);
00111 
00120       bool Intersect_Circle(const double & radius, const fmatvec::Vec3& CenCir);
00121       /***************************************************/
00122 
00123 #ifdef HAVE_OPENMBVCPPINTERFACE
00124       BOOST_PARAMETER_MEMBER_FUNCTION( (void), enableOpenMBV, tag, (optional (diffuseColor,(const fmatvec::Vec3&),"[-1;1;1]")(transparency,(double),0))) { 
00125         OpenMBVCuboid ombv(fmatvec::Vec3(),diffuseColor,transparency);
00126         openMBVRigidBody=ombv.createOpenMBV(); 
00127       }
00128 #endif
00129 
00130     protected:
00131       double yLength, zLength, thickness;
00132       //vertices under reference frame
00136       fmatvec::Vec3 RrA;
00137 
00141       fmatvec::Vec3 RrB;
00142 
00146       fmatvec::Vec3 RrC;
00147 
00151       fmatvec::Vec3 RrD;
00152 
00153     private:
00157       void setVertices();
00158 
00159   };
00160 }
00161 
00162 #endif /* _AREA_H_ */