Main Page | Class Hierarchy | Alphabetical List | Class List | File List | Class Members | File Members

CappedRectangle.h

Go to the documentation of this file.
00001 #ifndef CAPPEDRECTANGLE_H
00002 #define CAPPEDRECTANGLE_H
00003 
00004 #include "PhysicalObject.h"
00005 class Border;
00006 class Circle;
00007 
00013 class CappedRectangle : public PhysicalObject {
00014 
00015 public:
00016    CappedRectangle(real l, real R,                    
00017       real x = 0, real y = 0, real alpha = 0, std::string label="",
00018       int nSensorsLateral=0, int nSensorsSemicircle=0,
00019       real saturationForce=0.5,
00020       Color outlineColor = GUI::colorBlack, Color fillColor = GUI::colorTransparent
00021    );
00023    virtual ~CappedRectangle();
00024 
00026    virtual void computeMass(real density = ThyrixParameters::defaultDensity);
00027 
00029    virtual void computeInertia();
00030 
00031   virtual bool detectContacts(PhysicalObject* object,  GlobalContactInfoVector* contacts) {
00032       return object->detectContacts(this, contacts);
00033   }
00034 
00036    bool detectContacts(Border* border, GlobalContactInfoVector* contacts);
00037 
00039    bool detectContacts(Circle* circle,  GlobalContactInfoVector* contacts);
00040 
00042    bool detectContacts(CappedRectangle* capsule, GlobalContactInfoVector* contacts);
00043 
00048    bool detectMouseContact(const Vector2& rMouse, Vector2& p, PhysicalObject*& object);
00049 
00050    virtual void computeBox(){
00051       cosAlpha=cos(alpha);
00052       sinAlpha=sin(alpha);
00053       Vector2 rt(fabs(l*cosAlpha),fabs(l*sinAlpha));
00054       rt+=R+ThyrixParameters::halfEpsilonContact;
00055       boxMin=r; boxMin-=rt;
00056       boxMax=r; boxMax+=rt;
00057    }
00058 
00059    virtual void setSensor(ContactInfo* contact);
00060    
00062    void draw(GUI *gui);
00063 
00065    void drawSensors(GUI *gui);
00066 
00067 //private:
00070    real l;
00071    real R;
00072 
00074    real cosAlpha;
00076    real sinAlpha;
00077 
00079    unsigned nSensorsLateral;
00080 
00082    unsigned nSensorsSemicircle;
00083 
00084 private:
00088    int getISensorSemicircle(Vector2& p, int sign);
00089 
00094    void setISensorLateral(int& i1, int& i2, Vector2& p, real e1, real e2);
00095 
00099    int getISensorLateral(Vector2& p, real e);
00100 
00105    int getISensorLateral(real side, real e);
00106 
00109    real getLateralSide(Vector2& p){
00110       return -p.x*sinAlpha+p.y*cosAlpha;
00111    }
00112 
00113 };
00114 
00115 #endif //CAPPEDRECTANGLE_H

Thyrix homepageUsers' guide

(C) Arxia 2004-2005