00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
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
00052 std::string getType() const {
00053 return "Rectangle";
00054 }
00055 virtual void init(InitStage stage);
00056
00057
00058
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
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
00095 bool PointInRectangle(const fmatvec::Vec3& Point);
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
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