Rev 1221 | Details | Compare with Previous | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
15 | Werner | 1 | //--------------------------------------------------------------------------- |
2 | |||
3 | #ifndef HemiGrid_H |
||
4 | #define HemiGrid_H |
||
5 | |||
6 | /** HemiGrid represents a grid covering the hemisphehre as well as some operations. |
||
7 | The sky is modeled as equally sized tiles. |
||
24 | Werner | 8 | Coordinate system: |
9 | azimuth: angle between -pi .. +pi, where 0=south direction |
||
10 | elevation: 0: horizon - pi/2 (90°) |
||
15 | Werner | 11 | */ |
12 | class HemiGrid |
||
13 | { |
||
14 | public: |
||
15 | HemiGrid(): mMatrix(0), mMatrixCountAzimuth(-1), |
||
16 | mMatrixCountElevation(-1) {} |
||
17 | ~HemiGrid() { if (mMatrix) delete[] mMatrix; } |
||
25 | Werner | 18 | HemiGrid(const HemiGrid& grid) { setup(mCellSizeDegree); modify(grid, HemiGrid::SetTo); } |
15 | Werner | 19 | |
20 | void setup(double cellsize_degree); |
||
21 | void clear(double SetWith = 0.); |
||
22 | //void DumpGrid(TStrings* List); |
||
23 | |||
25 | Werner | 24 | double& rGetByIndex(const int iAzimuth, const int iElevation) const; |
25 | double& rGet(const double Azimuth, const double Elevation) const; |
||
15 | Werner | 26 | |
25 | Werner | 27 | /// get azimuth index of given azimuth angle. angle should be -pi .. pi. |
28 | int indexAzimuth(double Azimuth) const { int x=int( (Azimuth + M_PI) / (2.*M_PI) * mMatrixCountAzimuth ); if (x==mMatrixCountAzimuth) --x; return x;} |
||
29 | /// get index of elevation (0..pi/2) |
||
30 | int indexElevation(double Elevation) const { int x=int( Elevation / (M_PI / 2.) * mMatrixCountElevation ); if (x==mMatrixCountElevation) --x; return x;} |
||
15 | Werner | 31 | |
25 | Werner | 32 | /// get azimuth angle associated with given index. @return from -pi .. pi. |
33 | double azimuth(const int iAzimuth) { return iAzimuth/double(mMatrixCountAzimuth) * M_PI*2 - M_PI; } |
||
402 | werner | 34 | /// get azimuth angle associated with given index. @return 0 (North) -> pi/2 (West) -> pi (South) -> 3pi/2 (East) |
35 | double azimuthNorth(const int iAzimuth) { double d = iAzimuth/double(mMatrixCountAzimuth) * M_PI*2 - M_PI/2.; return d; } |
||
25 | Werner | 36 | /// get elevation angle associated with given index. @return from 0..pi/2 |
37 | double elevation(const int iElevation) { return iElevation/double(mMatrixCountElevation) * M_PI_2; } |
||
38 | |||
24 | Werner | 39 | int matrixCountAzimuth() const { return mMatrixCountAzimuth; } |
40 | int matrixCountElevation() const { return mMatrixCountElevation; } |
||
29 | Werner | 41 | /// get mininum and maximum value in the grid. |
25 | Werner | 42 | void matrixMinMax(double &rMatrixMin, double &rMatrixMax) const; |
29 | Werner | 43 | /// get sum of all cell values with elevation >= "elevation". |
772 | werner | 44 | double sum(const double elevation=0) const; |
15 | Werner | 45 | |
46 | static void projectLine(const double &x, const double &y, const double &deltah, const double &r, |
||
47 | double &elevation, double &azimuth1, double &azimuth2); |
||
48 | |||
49 | enum ModifyMode { Add, Multiply, SetTo }; |
||
29 | Werner | 50 | /** combine two Hemigrids. |
51 | use "Source" and combine it with curernt grid using the combine mode "mode". |
||
52 | Available modes are: Add, Multiply, Set (=copy). |
||
53 | @param Source Hemigrid used as source (is const, and not modified). |
||
54 | @param mode Combine mode (Add, Multiply, SetTo) */ |
||
15 | Werner | 55 | void modify(const HemiGrid &Source, const ModifyMode mode); |
56 | |||
57 | void projectCylinder(const double &deltax, const double &deltay, |
||
58 | const double &offsetz, const double &height, const double &r, |
||
59 | const ModifyMode mode, const double &value); |
||
60 | void modifyAngleRect( const double &elow, const double &alow1, const double &alow2, |
||
61 | const double &ehigh, const double &ahigh1, const double &ahigh2, |
||
62 | const ModifyMode mode, const double &value); |
||
63 | double getSum(const HemiGrid *Weighter=NULL) const; |
||
25 | Werner | 64 | // drawing/output |
65 | void paintGrid(QImage &image) const; |
||
66 | QString dumpGrid() const; |
||
15 | Werner | 67 | |
68 | private: |
||
69 | double* mMatrix; |
||
70 | int mMatrixCountAzimuth; |
||
71 | int mMatrixCountElevation; |
||
72 | double mMatrixCellSize; |
||
25 | Werner | 73 | double mCellSizeDegree; |
15 | Werner | 74 | }; |
75 | |||
76 | //--------------------------------------------------------------------------- |
||
77 | #endif |