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 namespace MBSim {
00029 
00035   class Rectangle : public Plane {
00036     public:
00041       Rectangle(const std::string &name);
00042 
00043       /* INHERITED INTERFACE OF ELEMENT */
00044       std::string getType() const {
00045         return "Rectangle";
00046       }
00047       virtual void init(InitStage stage);
00048       /**********************************/
00049 
00050       /* GETTER / SETTER */
00051       void setYLength(double l) {
00052         yLength = l;
00053       }
00054       void setZLength(double l) {
00055         zLength = l;
00056       }
00057       void setThickness(double thickness_) {thickness = thickness_;}
00058 
00059       double getYLength() const {
00060         return yLength;
00061       }
00062       double getZLength() const {
00063         return zLength;
00064       }
00065       //get vertex of the rectangle, under reference frame of the rectangle
00066       const fmatvec::Vec3 & getA() const {
00067         return RrA;
00068       }
00069       const fmatvec::Vec3 & getB() const {
00070         return RrB;
00071       }
00072       const fmatvec::Vec3 & getC() const {
00073         return RrC;
00074       }
00075       const fmatvec::Vec3 & getD() const {
00076         return RrD;
00077       }
00078       double getThickness() const {return thickness;}
00079 
00080       /***************************************************//*new added part by ting 05.10.2012*/
00087       bool PointInRectangle(const fmatvec::Vec3& Point); //need to be check again.......................................................
00088 
00096       bool PointInCircle(const fmatvec::Vec3& Point, const fmatvec::Vec3& CenCir, const double & radius);
00097 
00102       fmatvec::Vec3 Point_closest_toCircle_onLineseg(const fmatvec::Vec3& EndP1, const fmatvec::Vec3& EndP2, const fmatvec::Vec3& CenCir);
00103 
00112       bool Intersect_Circle(const double & radius, const fmatvec::Vec3& CenCir);
00113       /***************************************************/
00114 
00115 #ifdef HAVE_OPENMBVCPPINTERFACE
00116       virtual void enableOpenMBV(bool enable = true, int number = 10);
00117 #endif
00118 
00119     protected:
00120       double yLength, zLength, thickness;
00121       //vertices under reference frame
00125       fmatvec::Vec3 RrA;
00126 
00130       fmatvec::Vec3 RrB;
00131 
00135       fmatvec::Vec3 RrC;
00136 
00140       fmatvec::Vec3 RrD;
00141 
00142     private:
00146       void setVertices();
00147 
00148   };
00149 }
00150 
00151 #endif /* _AREA_H_ */