LightBase.h

00001 //---------------------------------------------------------------------------
00002 
00003 #ifndef LightBaseH
00004 #define LightBaseH
00005 //---------------------------------------------------------------------------
00006 #include "BehaviorBase.h"
00007 #include "Constants.h"
00008 #include <math.h>
00009 
00010 class clSimManager;
00011 class clTree;
00012 class clTreePopulation;
00013 class clLightOrg;
00014 class clPlot;
00015 class clAllometry;
00016 
00048 class clLightBase : virtual public clBehaviorBase {
00049 //note: need the virtual keyword to avoid base class ambiguity.
00050 
00051   friend class clLightOrg;
00052   friend class clLightBase;
00053   friend class clGliLight;
00054   friend class clQuadratGliLight;
00055   friend class clGLIMap;
00056   friend class clGLIPoints;
00057 
00058   public:
00065   clLightBase(clSimManager *p_oSimManager);
00066 
00070   virtual ~clLightBase();
00071 
00078   void Action();
00079 
00086   void RegisterTreeDataMembers();
00087 
00100   virtual float CalcLightValue(clTree *p_oTree, clTreePopulation *p_oPop) = 0;
00101 
00107   clLightOrg* GetLightOrg() {return mp_oLightOrg;};
00108 
00109   protected:
00110 
00111   static clLightOrg *mp_oLightOrg; 
00114   bool m_bHooked; 
00116   bool m_bNeedsCommonParameters; 
00121   //Variables that all light objects need but will keep their own copies of
00122   float **mp_fBrightness; 
00126   float **mp_fPhoto;      
00130   float m_fMinSunAngle;   
00133   int m_iNumAziAng;  
00135   int m_iNumAltAng; 
00137   int m_iMinAngRow; 
00149   void GetData(xercesc::DOMDocument *p_oDoc);
00150 
00156   virtual void DoShellSetup(xercesc::DOMDocument *p_oDoc){;};
00157 
00167   void PopulateGLIBrightnessArray();
00168 
00178   void PopulateSailLightBrightnessArray();
00179 
00180 
00181 
00182  //Solar geometry equations - inline
00183 
00190  inline float GetDayAngle(int iJulianDay)
00191                    {return (2*M_PI*(iJulianDay-1))/365;};
00192 
00199  inline float GetDeclination(float &fDayAngle) {
00200       return 0.006918 - (0.399912*cos(fDayAngle))+
00201       (0.070257*sin(fDayAngle))-(0.006758*cos(2*fDayAngle))+
00202       (0.000907*sin(2*fDayAngle))-(0.002697*cos(3*fDayAngle))+
00203       (0.00148*sin(3*fDayAngle));
00204  };
00205 
00212  inline float GetEccentricity(float &fDayAngle) {
00213       return 1.000110+(0.034221*cos(fDayAngle))+(0.001280*
00214       sin(fDayAngle))-(0.000719*cos(2*fDayAngle))+(0.000077*sin(2*fDayAngle));
00215  };
00216 
00224  inline float GetSunrise(float &fLatInRadians, float &fDeclination) {
00225       //compute sunrise and sunset times in radians from noon
00226       //x = cos(hour angle) when sun is at the horizon
00227       float x = (-1.0*sin(fLatInRadians)*sin(fDeclination))/(cos(fLatInRadians)*
00228                                                             cos(fDeclination));
00229       //but I don't understand how you get to sunrise - LEM
00230       return ((M_PI/2) - atan(x/(sqrt(1-x*x))));
00231  };
00232 
00242  inline float GetCosineOfZenithAngle(float &fDeclination, float &fLatInRadians,
00243                              float &fTimeNow) {
00244    return (sin(fDeclination)*sin(fLatInRadians))+
00245                 (cos(fDeclination)*cos(fLatInRadians)*cos(fTimeNow));
00246  };
00247 
00253  inline float GetAltitudeAngle(float &fCosZenAng) {
00254       //fCosZenAng is cosine of zenith angle - acos it to get the angle, and
00255       //subtract from pi/2 to get the altitude angle
00256       if (fCosZenAng <= -1.0)
00257          return ((M_PI/2.0) - acos(-1));
00258       else if (fCosZenAng >= 1.0)
00259         return ((M_PI/2.0) - acos(1));
00260       else return ((M_PI/2.0) - acos(fCosZenAng));
00261  };
00262 
00273  inline float GetAzimuthAngle(float &fDeclination, float &fLatInRadians,
00274                               float &fAltInRad, float &fTimeNow) {
00275         float fCosAzi = (((sin(fAltInRad)*sin(fLatInRadians))-sin(fDeclination))/
00276                      (cos(fLatInRadians)*cos(fAltInRad)));
00277         if (fCosAzi <= -1.0)   //just error checking. It is possible above line
00278            fCosAzi = -1.0;         //results in domain error
00279         else if (fCosAzi >= 1.0)
00280           fCosAzi = 1.0;
00281         fCosAzi = acos(fCosAzi);
00282         //convert to our azimuth system
00283         if (fCosAzi <= M_PI)
00284           return (M_PI - fCosAzi);
00285         else
00286           return ((3*M_PI) - fCosAzi);
00287  };
00288 
00296  inline float GetAirmassEffect(float &fAltInDeg, float &fCosZenAng) {
00297         if (fAltInDeg <= 5) return 10.39;
00298         else if ((fAltInDeg > 5) && (fAltInDeg <= 15)) return 5.60;
00299         else if ((fAltInDeg >15) && (fAltInDeg <= 25)) return 2.90;
00300         else return (1/fCosZenAng);
00301  };
00302 
00311  inline float GetBeamRadiation(float &fClearSkyTransCoeff, float &fAirmass,
00312                                float &fEccentricity, float &fCosZenAng) {
00313         return (pow(fClearSkyTransCoeff,fAirmass)*fEccentricity*fCosZenAng);
00314  };
00315 
00324   virtual float GetLightExtinctionCoefficient(clTree *p_oTree);
00325 };
00326 clLightOrg *clLightBase::mp_oLightOrg = NULL;
00327 //---------------------------------------------------------------------------
00328 #endif

Generated on Thu Jan 26 13:44:33 2006 for SORTIE Core C++ Documentation by  doxygen 1.4.6-NO