00001
00002
00003
00004
00005
00006
00007
00008
00009
00010 #ifndef __FieldDimensions_h_
00011 #define __FieldDimensions_h_
00012 #include "Math/Geometry.h"
00013 #include "Math/Common.h"
00014
00015
00016
00017
00018 #define HUGE_FIELD
00019
00020 #ifdef HUGE_FIELD
00021
00022 static const int xPosOpponentFieldBorder = 3000;
00023 static const int xPosOpponentGoal = 3000;
00024 static const int xPosFrontFlags = 1350;
00025 static const int xPosOpponentGoalpost = 2700;
00026 static const int xPosOpponentGroundline = 2700;
00027 static const int xPosOpponentSideCorner = 2700;
00028 static const int xPosOpponentPenaltyArea = 2050;
00029 static const int xPosHalfWayLine = 0;
00030
00031 static const int xPosOwnPenaltyArea = -xPosOpponentPenaltyArea;
00032 static const int xPosOwnSideCorner = -xPosOpponentSideCorner;
00033 static const int xPosOwnGroundline = -xPosOpponentGroundline;
00034 static const int xPosOwnGoalpost = -xPosOpponentGoalpost;
00035 static const int xPosBackFlags = -xPosFrontFlags;
00036 static const int xPosOwnGoal = -xPosOpponentGoal;
00037 static const int xPosOwnFieldBorder = -xPosOpponentFieldBorder;
00038
00039 static const int yPosLeftFieldBorder = 2000;
00040 static const int yPosLeftFlags = 1950;
00041 static const int yPosLeftSideline = 1800;
00042 static const int yPosLeftGroundline = 1800;
00043 static const int yPosLeftPenaltyArea = 650;
00044 static const int yPosLeftGoal = 400;
00045 static const int yPosCenterGoal = 0;
00046 static const int yPosRightGoal = -yPosLeftGoal;
00047 static const int yPosRightPenaltyArea = -yPosLeftPenaltyArea;
00048 static const int yPosRightGroundline = -yPosLeftGroundline;
00049 static const int yPosRightSideline = -yPosLeftSideline;
00050 static const int yPosRightFlags = -yPosLeftFlags;
00051 static const int yPosRightFieldBorder = -yPosLeftFieldBorder;
00052
00053
00054 static const int xPosYellowGroundline = xPosOpponentGroundline;
00055 static const int xPosYellowSideCorner = xPosOpponentSideCorner;
00056 static const int xPosYellowPenaltyArea = xPosOpponentPenaltyArea;
00057 static const int xPosBluePenaltyArea = xPosOwnPenaltyArea;
00058 static const int xPosBlueSideCorner = xPosOwnSideCorner;
00059 static const int xPosBlueGroundline = xPosOwnGroundline;
00060
00061
00062 static const int centerCircleRadius = 180;
00063 static const double flagRadius = 51.5;
00064 static const int flagHeight = 200;
00065 static const int flagColorHeight = 100;
00066 static const int goalHeight = 300;
00067 static const int goalWidth = 2*yPosLeftGoal;
00068 static const int goalDepth = xPosOpponentGoal - xPosOpponentGroundline;
00069 static const double ballRadius = 43;
00070 static const int fieldLinesWidth = 25;
00071
00072
00073 static const int xPosThrowInPointOpponentHalf = 1700;
00074 static const int xPosThrowInPointCenter = 0;
00075 static const int xPosThrowInPointOwnHalf = -xPosThrowInPointOpponentHalf;
00076 static const int yPosThrowInPointLeft = yPosLeftSideline - 400;
00077 static const int yPosThrowInPointRight = -yPosThrowInPointLeft;
00078
00079 #else
00080 #ifdef LARGE_FIELD
00081
00082 static const int xPosOpponentFieldBorder = 2500;
00083 static const int xPosOpponentGoal = 2450;
00084 static const int xPosFrontFlags = 2200;
00085 static const int xPosOpponentGoalpost = 2200;
00086 static const int xPosOpponentGroundline = 2100;
00087 static const int xPosOpponentSideCorner = 1800;
00088 static const int xPosOpponentPenaltyArea = 1600;
00089 static const int xPosHalfWayLine = 0;
00090
00091 static const int xPosOwnPenaltyArea = -1600;
00092 static const int xPosOwnSideCorner = -1800;
00093 static const int xPosOwnGroundline = -2100;
00094 static const int xPosOwnGoalpost = -2200;
00095 static const int xPosBackFlags = -2200;
00096 static const int xPosOwnGoal = -2450;
00097 static const int xPosOwnFieldBorder = -xPosOpponentFieldBorder;
00098
00099 static const int yPosLeftFieldBorder = 1500;
00100 static const int yPosLeftFlags = 1450;
00101 static const int yPosLeftSideline = 1350;
00102 static const int yPosLeftGroundline = 1050;
00103 static const int yPosLeftPenaltyArea = 500;
00104 static const int yPosLeftGoal = 300;
00105 static const int yPosCenterGoal = 0;
00106 static const int yPosRightGoal = -300;
00107 static const int yPosRightPenaltyArea = -500;
00108 static const int yPosRightGroundline = -1050;
00109 static const int yPosRightSideline = -1350;
00110 static const int yPosRightFlags = -1450;
00111 static const int yPosLeftFieldBorder = -yPosLeftFieldBorder;
00112
00113
00114 static const int xPosYellowGroundline = 2100;
00115 static const int xPosYellowSideCorner = 1800;
00116 static const int xPosYellowPenaltyArea = 1600;
00117 static const int xPosBluePenaltyArea = -1600;
00118 static const int xPosBlueSideCorner = -1800;
00119 static const int xPosBlueGroundline = -2100;
00120
00121
00122 static const int centerCircleRadius = 180;
00123 static const double flagRadius = 51.5;
00124 static const int flagHeight = 200;
00125 static const int flagColorHeight = 100;
00126 static const int goalHeight = 300;
00127 static const double ballRadius = 43;
00128 static const int fieldLinesWidth = 25;
00129 static const int wallHeight = 100;
00130
00131
00132 static const int xPosThrowInPointOpponentHalf = 0;
00133 static const int xPosThrowInPointCenter = 0;
00134 static const int xPosThrowInPointOwnHalf = 0;
00135 static const int yPosThrowInPointLeft = 0;
00136 static const int yPosThrowInPointRight = 0;
00137
00138 #else
00139
00140
00141
00142
00143
00144 #ifdef GLASSBOX
00145
00146 static const int xPosOpponentGoal = 301;
00147 static const int xPosFrontFlags = 265;
00148 static const int xPosOpponentGoalpost = 241;
00149 static const int xPosOpponentGroundline = 240;
00150 static const int xPosOpponentSideCorner = 240;
00151 static const int xPosOpponentPenaltyArea = 200;
00152 static const int xPosHalfWayLine = 0;
00153
00154 static const int xPosOwnPenaltyArea = -200;
00155 static const int xPosOwnSideCorner = -240;
00156 static const int xPosOwnGroundline = -240;
00157 static const int xPosOwnGoalpost = -241;
00158 static const int xPosBackFlags = -265;
00159 static const int xPosOwnGoal = -301;
00160
00161 static const int yPosLeftFlags = 265;
00162 static const int yPosLeftSideline = 240;
00163 static const int yPosLeftPenaltyArea = 150;
00164 static const int yPosLeftGroundline = 150;
00165 static const int yPosLeftGoal = 150;
00166 static const int yPosCenterGoal = 0;
00167 static const int yPosRightGoal = -150;
00168 static const int yPosCenterRightHalf = -150;
00169 static const int yPosRightGroundline = -150;
00170 static const int yPosRightPenaltyArea = -150;
00171 static const int yPosRightSideline = -240;
00172 static const int yPosRightFlags = -265;
00173
00174
00175 static const int xPosYellowGroundline = 1400;
00176 static const int xPosYellowSideCorner = 1100;
00177 static const int xPosYellowPenaltyLine = 950;
00178 static const int xPosBluePenaltyLine = -950;
00179 static const int xPosBlueSideCorner = -1100;
00180 static const int xPosBlueGroundline = -1400;
00181
00182
00183 static const int centerCircleRadius = 1;
00184 static const double flagRadius = 27;
00185 static const int flagHeight = 100;
00186 static const int goalHeight = 100;
00187 static const double ballRadius = 43;
00188 static const int fieldLinesWidth = 25;
00189 static const int flagColorHeight = 50;
00190 static const int wallHeight = 100;
00191
00192
00193 static const int xPosThrowInPointOpponentHalf = 0;
00194 static const int xPosThrowInPointCenter = 0;
00195 static const int xPosThrowInPointOwnHalf = 0;
00196 static const int yPosThrowInPointLeft = 0;
00197 static const int yPosThrowInPointRight = 0;
00198
00199 #else
00200
00201 static const int xPosOpponentGoal = 1750;
00202 static const int xPosFrontFlags = 1531;
00203 static const int xPosOpponentGoalpost = 1470;
00204 static const int xPosOpponentGroundline = 1420;
00205 static const int xPosOpponentSideCorner = 1100;
00206 static const int xPosOpponentPenaltyArea = 1060;
00207 static const int xPosHalfWayLine = 0;
00208
00209 static const int xPosOwnPenaltyArea = -1060;
00210 static const int xPosOwnSideCorner = -1100;
00211 static const int xPosOwnGroundline = -1420;
00212 static const int xPosOwnGoalpost = -1470;
00213 static const int xPosBackFlags = -1531;
00214 static const int xPosOwnGoal = -1750;
00215
00216 static const int yPosLeftFlags = 1031;
00217 static const int yPosLeftSideline = 900;
00218 static const int yPosLeftPenaltyArea = 900;
00219 static const int yPosLeftGroundline = 600;
00220 static const int yPosLeftGoal = 300;
00221 static const int yPosCenterGoal = 0;
00222 static const int yPosRightGoal = -300;
00223 static const int yPosCenterRightHalf = -500;
00224 static const int yPosRightGroundline = -600;
00225 static const int yPosRightPenaltyArea = -900;
00226 static const int yPosRightSideline = -900;
00227 static const int yPosRightFlags = -1031;
00228
00229
00230 static const int xPosYellowGroundline = 1400;
00231 static const int xPosYellowSideCorner = 1100;
00232 static const int xPosYellowPenaltyLine = 950;
00233 static const int xPosBluePenaltyLine = -950;
00234 static const int xPosBlueSideCorner = -1100;
00235 static const int xPosBlueGroundline = -1400;
00236
00237
00238 static const int centerCircleRadius = 150;
00239 static const double flagRadius = 50;
00240 static const int flagHeight = 200;
00241 static const int goalHeight = 300;
00242 static const double ballRadius = 43;
00243 static const int fieldLinesWidth = 25;
00244 static const int flagColorHeight = 100;
00245 static const int wallHeight = 100;
00246
00247
00248 static const int xPosThrowInPointOpponentHalf = 0;
00249 static const int xPosThrowInPointCenter = 0;
00250 static const int xPosThrowInPointOwnHalf = 0;
00251 static const int yPosThrowInPointLeft = 0;
00252 static const int yPosThrowInPointRight = 0;
00253
00254 #endif // GLASSBOX
00255 #endif // LARGE_FIELD
00256 #endif // HUGE_FIELD
00257
00258 static const Vector2<int>
00259 ownGroundlineLeft(xPosOwnGroundline,yPosLeftGroundline);
00260 static const Vector2<int>
00261 ownGroundlineRight(xPosOwnGroundline,yPosRightGroundline);
00262 static const Vector2<int>
00263 ownGoalRearPanelMiddle(xPosOwnGoal,yPosCenterGoal);
00264 static const Vector2<int>
00265 opponentGoalRearPanelMiddle(xPosOpponentGoal,yPosCenterGoal);
00266 static const Vector2<int>
00267 opponentGroundlineLeft(xPosOpponentGroundline,yPosLeftGroundline);
00268 static const Vector2<int>
00269 opponentGroundlineRight(xPosOpponentGroundline,yPosRightGroundline);
00270
00271
00272 static const Vector2<int>
00273 leftSideLineOwnEnd(xPosOwnSideCorner,yPosLeftSideline);
00274 static const Vector2<int>
00275 leftSideLineOpponentEnd(xPosOpponentSideCorner,yPosLeftSideline);
00276 static const Vector2<int>
00277 rightSideLineOwnEnd(xPosOwnSideCorner,yPosRightSideline);
00278 static const Vector2<int>
00279 rightSideLineOpponentEnd(xPosOpponentSideCorner,yPosRightSideline);
00280
00281 static const Vector2<int>
00282 ownGoalLeftPost(xPosOwnGroundline,yPosLeftGoal);
00283 static const Vector2<int>
00284 ownGoalRightPost(xPosOwnGroundline,yPosRightGoal);
00285 static const Vector2<int>
00286 opponentGoalLeftPost(xPosOpponentGroundline,yPosLeftGoal);
00287 static const Vector2<int>
00288 opponentGoalRightPost(xPosOpponentGroundline,yPosRightGoal);
00289
00290 static const Vector2<int>
00291 ownGoalLeftRearPanel(xPosOwnGoal,yPosLeftGoal);
00292 static const Vector2<int>
00293 ownGoalRightRearPanel(xPosOwnGoal,yPosRightGoal);
00294 static const Vector2<int>
00295 opponentGoalLeftRearPanel(xPosOpponentGoal,yPosLeftGoal);
00296 static const Vector2<int>
00297 opponentGoalRightRearPanel(xPosOpponentGoal,yPosRightGoal);
00298
00299
00300
00301 static const Geometry::Line leftWall
00302 (leftSideLineOwnEnd,
00303 leftSideLineOpponentEnd - leftSideLineOwnEnd);
00304
00305 static const Geometry::Line opponentLeftCorner
00306 (leftSideLineOpponentEnd,
00307 opponentGroundlineLeft - leftSideLineOpponentEnd);
00308
00309 static const Geometry::Line opponentLeftGroundline
00310 (opponentGroundlineLeft,
00311 opponentGoalLeftPost - opponentGroundlineLeft);
00312
00313 static const Geometry::Line opponentGoalLeftWall
00314 (opponentGoalLeftPost,
00315 opponentGoalLeftRearPanel - opponentGoalLeftPost);
00316
00317 static const Geometry::Line opponentGoalRearWall
00318 (opponentGoalLeftRearPanel,
00319 opponentGoalRightRearPanel - opponentGoalLeftRearPanel);
00320
00321 static const Geometry::Line opponentGoalRightWall
00322 (opponentGoalRightRearPanel,
00323 opponentGoalRightPost - opponentGoalRightRearPanel);
00324
00325 static const Geometry::Line opponentRightGroundline
00326 (opponentGoalRightPost,
00327 opponentGroundlineRight - opponentGoalRightPost);
00328
00329 static const Geometry::Line opponentRightCorner
00330 (opponentGroundlineRight,
00331 rightSideLineOpponentEnd - opponentGroundlineRight);
00332
00333 static const Geometry::Line rightWall
00334 (rightSideLineOpponentEnd,
00335 rightSideLineOwnEnd - rightSideLineOpponentEnd);
00336
00337 static const Geometry::Line ownRightCorner
00338 (rightSideLineOwnEnd,
00339 ownGroundlineRight - rightSideLineOwnEnd);
00340
00341 static const Geometry::Line ownRightGroundline
00342 (ownGroundlineRight,
00343 ownGoalRightPost - ownGroundlineRight);
00344
00345 static const Geometry::Line ownGoalRightWall
00346 (ownGoalRightPost,
00347 ownGoalRightRearPanel - ownGoalRightPost);
00348
00349 static const Geometry::Line ownGoalRearWall
00350 (ownGoalRightRearPanel,
00351 ownGoalLeftRearPanel - ownGoalRightRearPanel);
00352
00353 static const Geometry::Line ownGoalLeftWall
00354 (ownGoalLeftRearPanel,
00355 ownGoalLeftPost - ownGoalLeftRearPanel);
00356
00357 static const Geometry::Line ownLeftGroundline
00358 (ownGoalLeftPost,
00359 ownGroundlineLeft - ownGoalLeftPost);
00360
00361 static const Geometry::Line ownLeftCorner
00362 (ownGroundlineLeft,
00363 leftSideLineOwnEnd - ownGroundlineLeft);
00364
00365 static const int numOfLandmarks = 13;
00366
00367
00368
00369
00370
00371
00372
00373
00374 static const class Landmark
00375 {
00376 public:
00377 enum LandmarkType
00378 {
00379 pinkAboveYellow, pinkAboveSkyblue,
00380 yellowAbovePink, skyblueAbovePink,
00381 ownGoal, opponentGoal, fieldMarking,
00382 numberOfLandmarkTypes
00383 };
00384
00385 Landmark(int x, int y, int z, double sizeXY, double heightZ, int landmarkType):
00386 position((double)x, (double)y, (double)z), width(sizeXY), height(heightZ), kind(landmarkType)
00387 {;}
00388 Landmark(double x, double y, double z, double w, double h, int landmarkType):
00389 position(x, y, z), width(w), height(h), kind(landmarkType)
00390 {;}
00391
00392 Vector3<double> position;
00393 double width, height;
00394 int kind;
00395 }
00396 targetPointOnLandmark[numOfLandmarks] =
00397 {
00398 Landmark(xPosFrontFlags, yPosLeftFlags, flagHeight + (long )2.5*flagColorHeight, flagRadius, flagColorHeight, Landmark::skyblueAbovePink),
00399 Landmark(xPosFrontFlags, yPosRightFlags, flagHeight + (long )2.5*flagColorHeight, flagRadius, flagColorHeight, Landmark::pinkAboveSkyblue),
00400 Landmark(xPosBackFlags, yPosLeftFlags, flagHeight + (long )2.5*flagColorHeight, flagRadius, flagColorHeight, Landmark::yellowAbovePink),
00401 Landmark(xPosBackFlags, yPosRightFlags, flagHeight + (long )2.5*flagColorHeight, flagRadius, flagColorHeight, Landmark::pinkAboveYellow),
00402 Landmark(xPosOwnPenaltyArea, yPosLeftPenaltyArea, 0, 20.0, 0.0, Landmark::fieldMarking),
00403 Landmark(xPosOwnPenaltyArea, yPosRightPenaltyArea, 0, 20.0, 0.0, Landmark::fieldMarking),
00404 Landmark(xPosOpponentPenaltyArea, yPosLeftPenaltyArea, 0, 20.0, 0.0, Landmark::fieldMarking),
00405 Landmark(xPosOpponentPenaltyArea, yPosRightPenaltyArea, 0, 20.0, 0.0, Landmark::fieldMarking),
00406 Landmark(xPosHalfWayLine, 0, 0, 20.0, 0.0, Landmark::fieldMarking),
00407 Landmark(xPosHalfWayLine, yPosLeftGroundline, 0, 20.0, 0.0, Landmark::fieldMarking),
00408 Landmark(xPosHalfWayLine, yPosRightGroundline, 0, 20.0, 0.0, Landmark::fieldMarking),
00409 Landmark(xPosOpponentGoalpost, 0, (long )(1.2*goalHeight), (long )(1.2*yPosLeftGoal), goalHeight, Landmark::opponentGoal),
00410 Landmark(xPosOwnGoalpost, 0, (long )(1.2*goalHeight), (long )(1.2*yPosLeftGoal), goalHeight, Landmark::ownGoal)
00411 };
00412
00413
00414
00415
00416
00417
00418
00419 class FieldDimensions
00420 {
00421 public:
00422
00423
00424
00425 static bool isInsideField(const Vector2<int> &p);
00426
00427
00428
00429
00430 static bool isInsideField(int x, int y)
00431 {
00432 return isInsideField (Vector2<int>(x,y));
00433 }
00434
00435
00436
00437
00438 static bool isInsideGoal(const Vector2<int> &p);
00439
00440
00441
00442
00443 static bool isInsideGoal(int x, int y)
00444 {
00445 return isInsideGoal (Vector2<int>(x,y));
00446 }
00447
00448
00449
00450
00451 static bool isInsideOwnGoal(const Vector2<int> &p);
00452
00453
00454
00455
00456 static bool isInsideOpponentGoal(const Vector2<int> &p);
00457
00458
00459
00460
00461 static bool isOnOwnGoalGroundline(const Vector2<int> &p);
00462
00463
00464
00465
00466 static bool isOnOpponentGoalGroundline(const Vector2<int> &p);
00467
00468
00469
00470
00471 static double distanceToOpponentPenaltyArea(const Vector2<double> &p);
00472
00473
00474
00475
00476 static double distanceToOwnPenaltyArea(const Vector2<double> &p);
00477 static double distanceToOwnPenaltyArea(const Pose2D &p);
00478
00479
00480
00481
00482 static double distanceToBorder(const Vector2<double> &p);
00483
00484
00485
00486
00487 static void vectorToBorder(const Vector2<double> &p, Vector2<double> &result);
00488
00489
00490
00491
00492 static void vectorToBorderIncludingGoals(const Vector2<double> &p, Vector2<double> &result);
00493
00494
00495
00496
00497
00498
00499
00500
00501 static bool clipLineWithField(
00502 Vector2<int>& point1,
00503 Vector2<int>& point2
00504 );
00505
00506
00507
00508
00509
00510
00511
00512 static bool clipLineWithFieldAndGoalAreas(
00513 Vector2<int>& point1,
00514 Vector2<int>& point2
00515 );
00516 };
00517
00518 #endif //FieldDimensions