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