00001
00002
00003
00004
00005
00006
00007
00008
00009 #ifndef __Field_h_
00010 #define __Field_h_
00011
00012 #include "Representations/Perception/LinesPercept.h"
00013 #include "Representations/Perception/ObstaclesPercept.h"
00014 #include "Representations/Cognition/PlayerPoseCollection.h"
00015 #include "Tools/Boundary.h"
00016 #include "Tools/FieldDimensions.h"
00017 #include "Tools/Debugging/DebugDrawings.h"
00018 #include "Tools/Math/Pose2D.h"
00019
00020
00021
00022
00023 class Field : public Boundary<double>
00024 {
00025 private:
00026
00027
00028
00029 class Table
00030 {
00031 private:
00032 void free()
00033 {
00034 if(maxNumberOfEntries)
00035 {
00036 delete [] corner;
00037 delete [] length;
00038 maxNumberOfEntries = 0;
00039 }
00040 }
00041
00042 public:
00043 Pose2D* corner;
00044 double* length;
00045 int maxNumberOfEntries,
00046 numberOfEntries;
00047
00048 Table() {maxNumberOfEntries = 0;}
00049
00050 ~Table() {free();}
00051
00052 void setSize(int size)
00053 {
00054 if(size != maxNumberOfEntries)
00055 {
00056 free();
00057 if(size)
00058 {
00059 maxNumberOfEntries = size;
00060 corner = new Pose2D[size];
00061 length = new double[size];
00062 }
00063 }
00064 numberOfEntries = 0;
00065 }
00066
00067 void push(const Pose2D& p, double l)
00068 {
00069 corner[numberOfEntries] = p;
00070 length[numberOfEntries++] = l;
00071 }
00072 };
00073
00074 Table lines[LinesPercept::numberOfLineTypes + 5];
00075
00076 void initBoundary(Table& table);
00077 void initBoundaryForHugeField(Table& table);
00078 void initLines(Table& table, Table& xTable, Table& yTable);
00079 void initBorder(Table& table);
00080 void initBorderForHugeField(Table& table);
00081 void initOpponentGoal(Table& table);
00082 void initOwnGoal(Table& table);
00083 void initSimpleLines(Table& table);
00084 void initSimpleLinesForHugeField(Table& table);
00085
00086 void addCoords(Table& table,int number,double* x,double* y, bool rotate = false);
00087 void addCoords(Table& table,Table& xTable,Table& yTable,int number,double* x,double* y, bool rotate = false);
00088 void addPlayer(const Pose2D& pose);
00089
00090 public:
00091
00092
00093
00094 Field();
00095
00096
00097
00098
00099
00100
00101 bool isReallyInside(const Vector2<double>& v) const;
00102
00103
00104
00105
00106
00107
00108 double clip(Vector2<double>& v) const;
00109
00110
00111
00112
00113
00114
00115
00116 Vector2<double> getClosestPoint(const Vector2<double>& v, LinesPercept::LineType type) const;
00117
00118
00119
00120
00121
00122
00123
00124
00125
00126 bool getClosestPoint(Vector2<double>& point, const Pose2D& p, int numberOfRotations, LinesPercept::LineType type) const;
00127
00128
00129
00130
00131
00132
00133
00134 double getClosestDistance(const Vector2<double>& v, LinesPercept::LineType type) const;
00135
00136
00137
00138
00139
00140
00141
00142 double getDistance(const Pose2D& pose, LinesPercept::LineType type) const;
00143
00144
00145
00146
00147
00148
00149
00150 double getDistance(const Pose2D& pose,bool ignoreFieldLines = false) const;
00151
00152
00153
00154
00155
00156
00157 double getDistanceToOwnPenaltyArea(const Pose2D& pose) const;
00158
00159
00160
00161
00162
00163
00164
00165 double getObstacleDistance(const Pose2D& pose, ObstaclesPercept::ObstacleType& obstacleType) const;
00166
00167
00168
00169
00170
00171 void placePlayers(const PlayerPoseCollection& ppc);
00172
00173
00174
00175
00176
00177 Pose2D randomPose() const;
00178
00179
00180
00181
00182
00183
00184
00185 void draw(const Drawings::Color color, LinesPercept::LineType type) const;
00186 };
00187
00188 #endif // __Field_h_