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

VisualSensor.h

Go to the documentation of this file.
00001 #ifndef PROXIMITYSENSOR_H
00002 #define PROXIMITYSENSOR_H
00003 
00004 #include "PhysicalObject.h"
00005 
00012 class VisualSensor : public PhysicalObject  {
00013 public:
00017    VisualSensor(PhysicalObject* parent, real relativeX, real relativeY, 
00018       real relativeAlpha, real R, real viewAngle, unsigned int nSensors,
00019       std::string label="");
00020    virtual ~VisualSensor();
00021 
00022 
00024    virtual bool detectContacts(PhysicalObject* object, GlobalContactInfoVector* contacts) { 
00025       return object->detectContacts(this, contacts);
00026    }
00027    
00029    bool detectContacts(Border* border, GlobalContactInfoVector* contacts){
00030       return false;
00031    }
00032 
00034    bool detectContacts(Circle* circle,  GlobalContactInfoVector* contacts);
00035 
00037    bool detectContacts(CappedRectangle* capsule,  GlobalContactInfoVector* contacts);
00038 
00039 
00040    virtual void draw(GUI *gui);
00041 
00042 private:
00043 
00045    real R;
00046 
00048    real viewAngle;
00049    
00051    real delta;
00052 
00054    real epsilon;
00055 
00058    void activate(real gammaM, real gammaP);
00059 
00062    real computeGamma(real dx, real dy){
00063       real alpha0 = atan2(dy, dx); //-Pi..Pi
00064       
00065       real gamma = alpha0 - (parent->alpha+relativeAlpha);
00066       
00067       while (gamma <= -M_PI) {
00068          gamma += 2*M_PI; 
00069       } 
00070       while (gamma > M_PI) {
00071          gamma -= 2*M_PI;
00072       }
00073    
00074       //gamma is now between (-Pi,Pi]
00075       return gamma;
00076    }
00077 
00078    //real g1,g2; //used for debugging
00079 
00080 };
00081 
00082 #endif //PROXIMITYSENSOR_H

Thyrix homepageUsers' guide

(C) Arxia 2004-2005