00001 /** 00002 * @file Tools/Math/Geometry.h 00003 * Declares class Geometry 00004 * 00005 * @author <A href=mailto:juengel@informatik.hu-berlin.de>Matthias Jüngel</A> 00006 * @author <a href="mailto:walter.nistico@uni-dortmund.de">Walter Nistico</a> 00007 */ 00008 00009 #ifndef __Geometry_h__ 00010 #define __Geometry_h__ 00011 00012 #include "Tools/Math/Pose2D.h" 00013 #include "Representations/Perception/CameraMatrix.h" 00014 #include "Representations/Perception/CameraInfo.h" 00015 #include "Representations/Cognition/RobotPose.h" 00016 #include "Tools/Actorics/RobotDimensions.h" 00017 00018 00019 00020 00021 /** 00022 * The class Geometry defines representations for geometric objects and Methods 00023 * for calculations with such object. 00024 * 00025 */ 00026 class Geometry 00027 { 00028 public: 00029 00030 /** Defines a circle by its center and its radius*/ 00031 struct Circle 00032 { 00033 Circle(); 00034 Vector2<double> center; 00035 double radius; 00036 }; 00037 00038 /** Defines a line by two vectors*/ 00039 struct Line 00040 { 00041 Vector2<double> base; 00042 Vector2<double> direction; 00043 00044 Line() {}; 00045 Line(Vector2<double> base, Vector2<double> direction) : 00046 base(base), 00047 direction(direction) 00048 {}; 00049 00050 Line(Vector2<int> base, Vector2<double> direction) : 00051 direction(direction) 00052 { 00053 this->base.x = base.x; 00054 this->base.y = base.y; 00055 }; 00056 00057 Line(Vector2<int> base, Vector2<int> direction) 00058 { 00059 this->base.x = base.x; 00060 this->base.y = base.y; 00061 this->direction.x = direction.x; 00062 this->direction.y = direction.y; 00063 }; 00064 00065 00066 Line(double baseX, double baseY, double directionX, double directionY) 00067 { 00068 base.x = baseX; 00069 base.y = baseY; 00070 direction.x = directionX; 00071 direction.y = directionY; 00072 }; 00073 00074 void normalizeDirection(); 00075 }; 00076 00077 struct PixeledLine 00078 { 00079 PixeledLine(int x1, int x2, int y1, int y2):x1(x1),y1(y1),x2(x2),y2(y2) 00080 { 00081 calculatePixels(); 00082 }; 00083 00084 PixeledLine(Vector2<int> start, Vector2<int> end):x1(start.x),y1(start.y),x2(end.x),y2(end.y) 00085 { 00086 calculatePixels(); 00087 }; 00088 00089 void calculatePixels() 00090 { 00091 char sign; 00092 if(x1 == x2 && y1 == y2) 00093 { 00094 numberOfPixels = 0; 00095 } 00096 else //begin and end differ 00097 { 00098 if(abs(x2 - x1) > abs(y2 - y1) ) 00099 { 00100 if(x1 < x2) sign = 1; else sign = -1; 00101 numberOfPixels = abs(x2 - x1) + 1; 00102 for(int x = 0; x < numberOfPixels; x++) 00103 { 00104 int y = (int)(x * (y2 - y1) / (x2 - x1)); 00105 x_coordinate[x] = x1 + x*sign; 00106 y_coordinate[x] = y1 + y*sign; 00107 } 00108 } 00109 else 00110 { 00111 if(y1 < y2) sign = 1; else sign = -1; 00112 numberOfPixels = abs(y2 - y1) + 1; 00113 for(int y = 0; y < numberOfPixels; y++) 00114 { 00115 int x = (int)(y * (x2 - x1) / (y2 - y1)); 00116 x_coordinate[y] = x1 + x*sign; 00117 y_coordinate[y] = y1 + y*sign; 00118 } 00119 } 00120 } //begin and end differ 00121 }// calculatePixels 00122 00123 inline int getNumberOfPixels() const 00124 { 00125 return numberOfPixels; 00126 } 00127 00128 inline int getPixelX(int i) const 00129 { 00130 return x_coordinate[i]; 00131 } 00132 00133 inline int getPixelY(int i) const 00134 { 00135 return y_coordinate[i]; 00136 } 00137 00138 private: 00139 int x1, y1, x2, y2; 00140 int numberOfPixels; 00141 //enum{maxNumberOfPixelsInLine = 228}; //diagonal size of image 00142 enum{maxNumberOfPixelsInLine = 600}; //diagonal size of BW image 00143 int x_coordinate[maxNumberOfPixelsInLine]; 00144 int y_coordinate[maxNumberOfPixelsInLine]; 00145 }; 00146 00147 template <class V, int maxNumberOfPoints> class SetOfPoints 00148 { 00149 public: 00150 /** Constructor */ 00151 SetOfPoints() {init();} 00152 void add(V x, V y) 00153 { 00154 if(numberOfPoints >= maxNumberOfPoints) return; 00155 points[numberOfPoints].x = y; 00156 points[numberOfPoints].y = y; 00157 numberOfPoints++; 00158 } 00159 void add(Vector2<V> newPoint) 00160 { 00161 if(numberOfPoints >= maxNumberOfPoints) return; 00162 points[numberOfPoints] = newPoint; 00163 numberOfPoints++; 00164 } 00165 00166 void init() {numberOfPoints = 0;}; 00167 00168 double linearRegression(Line& line) 00169 { 00170 if(numberOfPoints == 0) return 0; 00171 double col1[maxNumberOfPoints], col2[maxNumberOfPoints], col3[maxNumberOfPoints], col4[maxNumberOfPoints], col5[maxNumberOfPoints]; 00172 double sumX, sumY, averageX, averageY, c3sum, c4sum, c5sum, m, n; 00173 00174 sumX=0; sumY=0; c3sum=0; c4sum=0; c5sum=0; 00175 00176 int i; 00177 for (i = 0; i < numberOfPoints; i++) 00178 { 00179 sumX = sumX + points[i].x; 00180 sumY = sumY + points[i].y; 00181 } 00182 00183 averageX = sumX / numberOfPoints; 00184 averageY = sumY / numberOfPoints; 00185 00186 for (i = 0; i < numberOfPoints; i++) 00187 { 00188 col1[i] = points[i].x - averageX; 00189 col2[i] = points[i].y - averageY; 00190 col3[i] = col1[i] * col2[i]; 00191 col4[i] = col1[i] * col1[i]; 00192 col5[i] = col2[i] * col2[i]; 00193 } 00194 00195 for (i = 0; i < numberOfPoints; i++) 00196 { 00197 c3sum = c3sum + col3[i]; 00198 c4sum = c4sum + col4[i]; 00199 c5sum = c5sum + col5[i]; 00200 } 00201 00202 m = c3sum / c4sum; 00203 n = averageY - m * averageX; 00204 00205 line.base.x = 0; 00206 line.base.y = n; 00207 line.direction.x = 1; 00208 line.direction.y = m; 00209 00210 // reliability: 00211 return fabs(c3sum / sqrt(c4sum * c5sum)); 00212 } 00213 private: 00214 Vector2<V> points[maxNumberOfPoints]; 00215 int numberOfPoints; 00216 }; 00217 00218 /** 00219 * Calculates the angle between a pose and a position 00220 * @param from The base pose. 00221 * @param to The other position. 00222 * @return the angle from the pose to the position. 00223 */ 00224 static double angleTo(const Pose2D& from, 00225 const Vector2<double>& to); 00226 00227 /** 00228 * Calculates the distance from a pose to a position 00229 * @param from The base pose. 00230 * @param to The other position. 00231 * @return the distance from the pose to the position. 00232 */ 00233 static double distanceTo(const Pose2D& from, 00234 const Vector2<double>& to); 00235 00236 /** 00237 * Calculates the relative vector from a pose to a position 00238 * @param from The base pose. 00239 * @param to The other position. 00240 * @return the vector from the pose to the position. 00241 */ 00242 static Vector2<double> vectorTo(const Pose2D& from, 00243 const Vector2<double>& to); 00244 00245 /** 00246 * Returns the circle defined by the three points. 00247 * @param point1 The first point. 00248 * @param point2 The second point. 00249 * @param point3 The third point. 00250 * @return The circle defined by point1, point2 and point3. 00251 */ 00252 static Circle getCircle( 00253 const Vector2<int> point1, 00254 const Vector2<int> point2, 00255 const Vector2<int> point3 00256 ); 00257 00258 static bool getIntersectionOfLines( 00259 const Line line1, 00260 const Line line2, 00261 Vector2<double>& intersection 00262 ); 00263 00264 static bool getIntersectionOfLines( 00265 const Line line1, 00266 const Line line2, 00267 Vector2<int>& intersection 00268 ); 00269 00270 static bool getIntersectionOfRaysFactor( 00271 const Line ray1, 00272 const Line ray2, 00273 double& intersection 00274 ); 00275 00276 static double getDistanceToLine( 00277 const Line line, 00278 const Vector2<double>& point 00279 ); 00280 00281 static double getDistanceToEdge( 00282 const Line line, 00283 const Vector2<double>& point 00284 ); 00285 00286 static double distance( 00287 const Vector2<double>& point1, 00288 const Vector2<double>& point2 00289 ); 00290 00291 static double distance( 00292 const Vector2<int>& point1, 00293 const Vector2<int>& point2 00294 ); 00295 00296 private: 00297 static double calculateScaleFactor( 00298 int y, 00299 unsigned long frameNumber, 00300 unsigned long prevFrameNumber, 00301 const CameraInfo& cameraInfo 00302 ); 00303 00304 public: 00305 static Vector3<double> rayFromCamera( 00306 int y, 00307 const CameraMatrix& cameraMatrix, 00308 const CameraMatrix& prevCameraMatrix, 00309 const Vector3<double> vector, 00310 const CameraInfo& cameraInfo 00311 ); 00312 00313 static void calculateAnglesForPoint( 00314 const Vector2<int>& point, 00315 const CameraMatrix& cameraMatrix, 00316 const CameraInfo& cameraInfo, 00317 Vector2<double>& angles 00318 ); 00319 00320 static void calculateAnglesForPoint( 00321 const Vector2<int>& point, 00322 const CameraMatrix& cameraMatrix, 00323 const CameraMatrix& prevCameraMatrix, 00324 const CameraInfo& cameraInfo, 00325 Vector2<double>& angles 00326 ); 00327 00328 static void calculatePointByAngles( 00329 const Vector2<double>& angles, 00330 const CameraMatrix& cameraMatrix, 00331 const CameraInfo& cameraInfo, 00332 Vector2<int>& point 00333 ); 00334 00335 static bool clipLineWithQuadrangle( 00336 const Line lineToClip, 00337 const Vector2<double>& corner0, 00338 const Vector2<double>& corner1, 00339 const Vector2<double>& corner2, 00340 const Vector2<double>& corner3, 00341 Vector2<double>& clipPoint1, 00342 Vector2<double>& clipPoint2 00343 ); 00344 00345 static bool clipLineWithQuadrangle( 00346 const Line lineToClip, 00347 const Vector2<double>& corner0, 00348 const Vector2<double>& corner1, 00349 const Vector2<double>& corner2, 00350 const Vector2<double>& corner3, 00351 Vector2<int>& clipPoint1, 00352 Vector2<int>& clipPoint2 00353 ); 00354 00355 static bool isPointInsideRectangle( 00356 const Vector2<double>& bottomLeftCorner, 00357 const Vector2<double>& topRightCorner, 00358 const Vector2<double>& point 00359 ); 00360 00361 static bool isPointInsideRectangle( 00362 const Vector2<int>& bottomLeftCorner, 00363 const Vector2<int>& topRightCorner, 00364 const Vector2<int>& point 00365 ); 00366 00367 static bool clipPointInsideRectange( 00368 const Vector2<int>& bottomLeftCorner, 00369 const Vector2<int>& topRightCorner, 00370 Vector2<int>& point 00371 ); 00372 00373 /** 00374 * Calculates where a pixel in the image lies on the ground (relative to the robot). 00375 * @param x Specifies the x-coordinate of the pixel. 00376 * @param y Specifies the y-coordinate of the pixel. 00377 * @param cameraMatrix The camera matrix of the image. 00378 * @param cameraInfo The camera info of the image. 00379 * @param pointOnField The resulting point. 00380 */ 00381 static bool calculatePointOnField( 00382 const int x, 00383 const int y, 00384 const CameraMatrix& cameraMatrix, 00385 const CameraInfo& cameraInfo, 00386 Vector2<int>& pointOnField 00387 ); 00388 00389 /** 00390 * Calculates where a pixel in the image lies on the ground (relative to the robot). 00391 * @param x Specifies the x-coordinate of the pixel. 00392 * @param y Specifies the y-coordinate of the pixel. 00393 * @param cameraMatrix The camera matrix of the image. 00394 * @param prevCameraMatrix The camera matrix of the previous image. 00395 * @param cameraInfo The camera info of the image. 00396 * @param pointOnField The resulting point. 00397 */ 00398 static bool calculatePointOnField( 00399 const int x, 00400 const int y, 00401 const CameraMatrix& cameraMatrix, 00402 const CameraMatrix& prevCameraMatrix, 00403 const CameraInfo& cameraInfo, 00404 Vector2<int>& pointOnField 00405 ); 00406 00407 /** 00408 * Calculates where a relative point on the ground appears in an image. 00409 * @param point The coordinates of the point relative to the robot's origin. 00410 * @param cameraMatrix The camera matrix of the image. 00411 * @param cameraInfo The camera info of the image. 00412 * @param pointInImage The resulting point. 00413 */ 00414 static void calculatePointInImage 00415 ( 00416 const Vector2<int>& point, 00417 const CameraMatrix& cameraMatrix, 00418 const CameraInfo& cameraInfo, 00419 Vector2<int>& pointInImage 00420 ); 00421 00422 /** 00423 * Clips a line with a rectangle 00424 * @param bottomLeft The bottom left corner of the rectangle 00425 * @param topRight The top right corner of the rectangle 00426 * @param line The line to be clipped 00427 * @param point1 The starting point of the resulting line 00428 * @param point2 The end point of the resulting line 00429 * @return states whether clipping was necessary (and done) 00430 */ 00431 static bool getIntersectionPointsOfLineAndRectangle( 00432 const Vector2<int>& bottomLeft, 00433 const Vector2<int>& topRight, 00434 const Geometry::Line line, 00435 Vector2<int>& point1, 00436 Vector2<int>& point2 00437 ); 00438 00439 00440 /** 00441 * Clips a line with the Cohen-Sutherland-Algorithm 00442 * @param bottomLeft The bottom left corner of the rectangle 00443 * @param topRight The top right corner of the rectangle 00444 * @param point1 The starting point of the line 00445 * @param point2 The end point of the line 00446 * @return states whether clipping was necessary (and done) 00447 */ 00448 static bool clipLineWithRectangleCohenSutherland( 00449 const Vector2<int>& bottomLeft, 00450 const Vector2<int>& topRight, 00451 Vector2<int>& point1, 00452 Vector2<int>& point2 00453 ); 00454 00455 /** 00456 * Clips a line with the Cohen-Sutherland-Algorithm if it has a point outside the rectangle. 00457 * Expands the line if it has a point inside the rectangle. 00458 * @param bottomLeft The bottom left corner of the rectangle 00459 * @param topRight The top right corner of the rectangle 00460 * @param point1 The starting point of the line 00461 * @param point2 The end point of the line 00462 */ 00463 /* 00464 static bool ExpandOrClipLineWithRectangleCohenSutherland( 00465 const Vector2<int>& bottomLeft, 00466 const Vector2<int>& topRight, 00467 Vector2<int>& point1, 00468 Vector2<int>& point2 00469 ); 00470 */ 00471 00472 /** 00473 * Calculates the Cohen Sutherland Code for a given point and a given rectangle 00474 */ 00475 static int cohenSutherlandOutCode( 00476 const Vector2<int>& bottomLeft, 00477 const Vector2<int>& topRight, 00478 Vector2<int>& point 00479 ) 00480 { 00481 int code; 00482 if ( point.x < bottomLeft.x ) 00483 code = 1 ; 00484 else 00485 code = 0 ; 00486 if ( point.x > topRight.x ) 00487 code += 2 ; 00488 if ( point.y < bottomLeft.y ) 00489 code += 4 ; 00490 if ( point.y > topRight.y ) 00491 code += 8 ; 00492 return(code) ; 00493 } 00494 00495 /** 00496 * Calculates the intersection of an arbitrary line and a horizontal or vertical line. 00497 */ 00498 static int intersection(int a1,int b1,int a2,int b2,int value); 00499 00500 /** 00501 * Function does the transformation from 2d relative robot coordinates 00502 * to absolute field coordinates. 00503 * @param rp current Robot Pose. 00504 * @param x relative x-coordinate of ball (relative to robot) 00505 * @param y relative y-coordinate of ball (relative to robot) 00506 * @return Returns the ball positon in absolute coordinates 00507 */ 00508 static Vector2<double> relative2FieldCoord(RobotPose rp, double x, double y); 00509 00510 /** 00511 * Function does the transformation from 2d field coordinates 00512 * to coordinates relative to the robot. 00513 * @param robotPose current Robot Pose. 00514 * @param fieldCoord 00515 * @return Returns the positon in relative 00516 */ 00517 static Vector2<double> fieldCoord2Relative(RobotPose robotPose, Vector2<double> fieldCoord); 00518 00519 00520 /** 00521 * The function approximates the shape of a ball in the camera image. 00522 * Note: currently, the approximation is not exact. 00523 * @param ballOffset The ball's position relative to the robot's body origin. 00524 * @param cameraMatrix The position and orientation of the robot's camera. 00525 * @param cameraInfo The resolution and the opening angle of the robot's camera. 00526 * @param circle The approximated shape generated by the function. 00527 * @return If false, only the center of the circle is valid, not the radius. 00528 */ 00529 static bool calculateBallInImage(const Vector2<double>& ballOffset, 00530 const CameraMatrix& cameraMatrix, 00531 const CameraInfo& cameraInfo, 00532 Circle& circle); 00533 00534 00535 static double getDistanceBySize 00536 ( 00537 const CameraInfo& cameraInfo, 00538 double sizeInReality, 00539 double sizeInPixels 00540 ); 00541 00542 /** 00543 * The function determines how far an object is away depending on its real size and the size in the image 00544 * along with its center position, using camera intrinsic parameters. 00545 * @param cameraInfo Class containing the intrinsic paramaters 00546 * @param sizeInReality The real size of the object. 00547 * @param sizeInPixels The size in the image. 00548 * @param centerX X coordinate (in image reference) of object's baricenter. 00549 * @param centerY Y coordinate (in image reference) of object's baricenter. 00550 * @return The distance between camera and object. 00551 */ 00552 static double getDistanceBySize( 00553 const CameraInfo& cameraInfo, 00554 double sizeInReality, 00555 double sizeInPixels, 00556 int centerX, 00557 int centerY 00558 ); 00559 00560 /** 00561 * The function determines how far an object is away depending on its real size and the size in the image. 00562 * @param sizeInReality The real size of the object. 00563 * @param sizeInPixels The size in the image. 00564 * @return The distance between camera and object. 00565 */ 00566 static double getDistanceByAngleSize( 00567 double sizeInReality, 00568 double sizeInPixels 00569 ); 00570 00571 /** 00572 * The function determines how far the ball is away depending on its real size and the size in the image. 00573 * @param sizeInReality The real size of the ball. 00574 * @param sizeInPixels The size in the image. 00575 * @return The distance between the camera and the ball. 00576 */ 00577 static double getBallDistanceByAngleSize( 00578 double sizeInReality, 00579 double sizeInPixels 00580 ); 00581 00582 /** 00583 * The function determines how big an object appears in the image depending on its distance and size. 00584 * @param sizeInReality The real size of the object. 00585 * @param distance The distance to the object. 00586 * @param imageWidthPixels The horizontal resolution of the image. 00587 * @param imageWidthAngle The horizontal opening angle of the camera. 00588 * @return The size as it would appear in the image. 00589 */ 00590 static double getSizeByDistance( 00591 double sizeInReality, 00592 double distance, 00593 double imageWidthPixels, 00594 double imageWidthAngle 00595 ); 00596 00597 /** 00598 * The function determines how big an object appears in the image depending on its distance and size. 00599 * @param cameraInfo Object containing camera paramters. 00600 * @param sizeInReality The real size of the object. 00601 * @param distance The distance to the object. 00602 * @return The size as it would appear in the image. 00603 */ 00604 static double getSizeByDistance 00605 ( 00606 const CameraInfo& cameraInfo, 00607 double sizeInReality, 00608 double distance 00609 ); 00610 00611 /** 00612 * The function calculates the horizon. 00613 * @param cameraMatrix The camera matrix. 00614 * @param cameraInfo Object containing camera parameters. 00615 * @return The line of the horizon in the image. 00616 */ 00617 static Geometry::Line calculateHorizon( 00618 const CameraMatrix& cameraMatrix, 00619 const CameraInfo& cameraInfo 00620 ); 00621 00622 /** 00623 * The function calculates the expected size (pixel) of a field line in an image. 00624 * @param pointInImage The point where the line is expected. 00625 * @param cameraMatrix The camera matrix. 00626 * @param cameraInfo Object containing the camera parameters. 00627 * @return The size of a line pixel. 00628 */ 00629 static int calculateLineSize( 00630 const Vector2<int>& pointInImage, 00631 const CameraMatrix& cameraMatrix, 00632 const CameraInfo& cameraInfo 00633 ); 00634 00635 /** 00636 * Calculates the angle size for a given pixel size. 00637 */ 00638 static double pixelSizeToAngleSize(double pixelSize, const CameraInfo& cameraInfo); 00639 00640 /** 00641 * Calculates the pixel size for a given angle size. 00642 */ 00643 static double angleSizeToPixelSize(double angleSize, const CameraInfo& cameraInfo); 00644 00645 /** 00646 * A radial distortion correction look-up table element 00647 */ 00648 struct CorrectedCoords { 00649 unsigned char x; 00650 unsigned char y; 00651 }; 00652 00653 /** 00654 * Corrects the radial distortion introduced by the camera lens (using a 4th order model) of a given pixel. 00655 * @param cameraInfo Class containing camera intrinsic parameters 00656 * @param srcX X coordinate (image reference) of pixel to be distortion-corrected. 00657 * @param srcY Y coordinate (image reference) of pixel to be distortion-corrected. 00658 * @param correctedX X coordinate (image reference) of resulting distortion-corrected pixel. 00659 * @param correctedY Y coordinate (image reference) of resulting distortion-corrected pixel. 00660 */ 00661 static inline void radialDistortionCorrection(const CameraInfo& cameraInfo, const int srcX, const int srcY, double& correctedX, double& correctedY){ 00662 double x1 = srcX - cameraInfo.opticalCenter.x; 00663 double y1 = srcY - cameraInfo.opticalCenter.y; 00664 double r_square = x1*x1 + y1*y1; 00665 double k1_num = cameraInfo.secondOrderRadialDistortion; 00666 double k1_den = cameraInfo.focalLenPow2; 00667 double k2_num = cameraInfo.fourthOrderRadialDistortion; 00668 double k2_den = cameraInfo.focalLenPow4; 00669 correctedX = srcX + x1*(k1_num*r_square/k1_den + k2_num*r_square*r_square/k2_den); 00670 correctedY = srcY + y1*(k1_num*r_square/k1_den + k2_num*r_square*r_square/k2_den); 00671 } 00672 00673 /** 00674 * This function builds a radial distortion correction look-up table based on the parameters contained in cameraInfo. 00675 * @param cameraInfo Object containing intrinisc (and other) camera parameters. 00676 */ 00677 static void setupRadialCorrection(const CameraInfo& cameraInfo); 00678 00679 static inline void setupRadialCorrectionERS7() 00680 { 00681 CameraInfo cameraInfo(RobotDesign::ERS7); 00682 setupRadialCorrection(cameraInfo); 00683 } 00684 00685 static inline void setupRadialCorrectionERS210() 00686 { 00687 CameraInfo cameraInfo(RobotDesign::ERS210); 00688 setupRadialCorrection(cameraInfo); 00689 } 00690 00691 inline static bool insideCircle(Geometry::Circle &circle,double radius2,double x,double y){ 00692 return (((circle.center.x-x)*(circle.center.x-x)\ 00693 + (circle.center.y-y)*(circle.center.y-y)) < radius2); 00694 } 00695 00696 /** 00697 * Corrects the radial distortion introduced by the camera lens (using a 4th order model) of a given pixel, 00698 * using a pre-computed look-up table. 00699 * @param srcX X coordinate (image reference) of pixel to be distortion-corrected. 00700 * @param srcY Y coordinate (image reference) of pixel to be distortion-corrected. 00701 * @param correctedX X coordinate (image reference) of resulting distortion-corrected pixel. 00702 * @param correctedY Y coordinate (image reference) of resulting distortion-corrected pixel. 00703 */ 00704 static inline void radialDistortionCorrectionFast(const int srcX, const int srcY, int& correctedX, int& correctedY) 00705 { 00706 CorrectedCoords result = radialCorrectionLUT[srcY][srcX]; 00707 correctedX = result.x; 00708 correctedY = result.y; 00709 } 00710 00711 private: 00712 static CorrectedCoords radialCorrectionLUT[cameraResolutionHeight_ERS7][cameraResolutionWidth_ERS7]; /** Radius look up table, used to index the correction table. */ 00713 }; 00714 00715 #endif //__Geometry_h____ 00716 00717 /* 00718 * Change log : 00719 * 00720 * $Log: Geometry.h,v $ 00721 * Revision 1.11 2004/09/09 11:37:39 wachter 00722 * - Fixed some more doxygen-errors 00723 * 00724 * Revision 1.10 2004/09/09 10:15:56 spranger 00725 * fixed doxygen-errors 00726 * 00727 * Revision 1.9 2004/06/14 23:20:09 spranger 00728 * -changed some functions in Geometry from int to double including ballradius(fieldimensions) 00729 * -maybe all Geometric-functions in Geometry should be as precise as possible, avoiding int to double conversion errors 00730 * 00731 * Revision 1.8 2004/06/13 21:22:14 nistico 00732 * Minor bug fixes 00733 * 00734 * Revision 1.7 2004/06/05 18:36:04 nistico 00735 * Cleanup 00736 * 00737 * Revision 1.6 2004/06/05 07:58:22 roefer 00738 * Compensation for motion distortions of images 00739 * 00740 * Revision 1.5 2004/06/04 21:35:10 juengel 00741 * Added getBallDistanceByAngleSize. 00742 * 00743 * Revision 1.4 2004/06/04 08:45:59 juengel 00744 * Added fieldCoord2Relative. 00745 * 00746 * Revision 1.3 2004/05/26 15:54:26 dueffert 00747 * camera matrix calculation cleaned up 00748 * 00749 * Revision 1.2 2004/05/22 22:52:03 juengel 00750 * Renamed ballP_osition to ballModel. 00751 * 00752 * Revision 1.1.1.1 2004/05/22 17:37:08 cvsadm 00753 * created new repository GT2004_WM 00754 * 00755 * Revision 1.15 2004/05/17 11:57:04 nistico 00756 * Imported ball detection from RasterImageProcessor (integrated in MSH by Bernd in New Orleans) 00757 * 00758 * Revision 1.14 2004/05/12 11:38:22 nistico 00759 * RadialDistortionCorrectionFast is now static 00760 * 00761 * Revision 1.13 2004/05/12 09:12:40 schumann 00762 * removed gcc error 00763 * 00764 * Revision 1.12 2004/05/07 15:16:25 nistico 00765 * All geometry calculations are making use of intrinsic functions. 00766 * I updated most of the images processors to make correct use of this. 00767 * Please test if there are any problems, because i'm going to remove the 00768 * old code soon. 00769 * 00770 * Revision 1.11 2004/04/18 18:14:53 nistico 00771 * USE_INTRINSIC layout removed. 00772 * All functions properly replicated in intrinsic version. 00773 * However, image processor (MSH2004) making use of them get distorted visualization 00774 * of percepts, because drawing functions use the old parameters. 00775 * It has to be decided wheter to fully move to intrinsic, or discard it. 00776 * 00777 * Revision 1.10 2004/04/09 21:32:33 roefer 00778 * USE_INTRINSIC is inconsistent in the simulator, so it is switched off 00779 * Do we really want to use it on the robot? 00780 * 00781 * Revision 1.9 2004/04/08 15:33:08 wachter 00782 * GT04 checkin of Microsoft-Hellounds 00783 * 00784 * Revision 1.8 2004/04/07 13:00:46 risler 00785 * ddd checkin after go04 - second part 00786 * 00787 * Revision 1.2 2004/03/30 20:21:45 park 00788 * changed PixeldeLine to work with BW Images 00789 * 00790 * Revision 1.1.1.1 2004/03/29 08:28:42 Administrator 00791 * initial transfer from tamara 00792 * 00793 * Revision 1.7 2004/03/09 11:35:23 nistico 00794 * - Sorry, conditional compilation switch is really located (as it should be) in Geometry.h, not CameraInfo.h 00795 * 00796 * Revision 1.6 2004/03/09 11:33:21 nistico 00797 * - Intrinsic parameters based measurements can now be triggered through a single conditional compilation 00798 * switch located in CameraInfo.h 00799 * - Implemented fast (look-up table based) radial distortion correction 00800 * 00801 * Revision 1.5 2004/02/10 10:48:05 nistico 00802 * Introduced Intrinsic camera parameters to perform geometric calculations (distance, angle, size...) without opening angle 00803 * Implemented radial distortion correction function 00804 * Implemented ball distance calculation based on size and intrinsic params (potentially more stable) 00805 * To Be Done: calculate intrinsic params for ERS7, as soon as we get our puppies back 00806 * 00807 * Revision 1.4 2004/01/28 08:27:40 dueffert 00808 * doxygen bug fixed 00809 * 00810 * Revision 1.3 2003/12/15 11:47:00 juengel 00811 * Introduced CameraInfo 00812 * 00813 * Revision 1.2 2003/11/10 11:34:05 juengel 00814 * Added class SetOfPoints. 00815 * 00816 * Revision 1.1 2003/10/07 10:13:24 cvsadm 00817 * Created GT2004 (M.J.) 00818 * 00819 * Revision 1.7 2003/09/26 15:28:10 juengel 00820 * Renamed DataTypes to representations. 00821 * 00822 * Revision 1.6 2003/09/26 11:40:40 juengel 00823 * - sorted tools 00824 * - clean-up in DataTypes 00825 * 00826 * Revision 1.5 2003/08/18 11:50:21 juengel 00827 * Added calculateLineSize. 00828 * 00829 * Revision 1.4 2003/08/09 14:53:10 dueffert 00830 * files and docu beautified 00831 * 00832 * Revision 1.3 2003/07/29 12:40:00 juengel 00833 * Added calculateHorizon 00834 * 00835 * Revision 1.2 2003/07/28 10:02:35 dueffert 00836 * access implications of member methods corrected 00837 * 00838 * Revision 1.1.1.1 2003/07/02 09:40:28 cvsadm 00839 * created new repository for the competitions in Padova from the 00840 * tamara CVS (Tuesday 2:00 pm) 00841 * 00842 * removed unused solutions 00843 * 00844 * Revision 1.23 2003/06/22 17:25:57 dueffert 00845 * getIntersectionPointsOfLineAndRectangle added 00846 * 00847 * Revision 1.22 2003/06/22 17:09:58 juengel 00848 * Added int version of function "distance". 00849 * 00850 * Revision 1.21 2003/06/15 14:26:44 jhoffman 00851 * + moved "relative2FieldCoord" to Geometry 00852 * + added member function to ballp_osition to calculate the propagated position and speed for a given time 00853 * + propagated speed and time calculation using exponential decay instead of using an iterative calculation 00854 * + in motion you can now use propageted ball pos at 125 Hz rather then the framerate determined by cognition 00855 * 00856 * Revision 1.20 2003/06/12 16:54:09 juengel 00857 * Added getDistanceBySize and getSizeByDistance. 00858 * 00859 * Revision 1.19 2003/06/10 17:59:04 juengel 00860 * Added constructor Line(Vector2<int> base, Vector2<int> direction) 00861 * 00862 * Revision 1.18 2003/04/16 07:00:17 roefer 00863 * Bremen GO checkin 00864 * 00865 * Revision 1.17 2003/04/15 15:52:07 risler 00866 * DDD GO 2003 code integrated 00867 * 00868 * Revision 1.16 2003/03/26 17:46:00 max 00869 * added getDistanceToEdge 00870 * optimized getDistanceToLine 00871 * 00872 * Revision 1.16 2003/04/01 16:51:09 roefer 00873 * CameraMatrix contains validity and is calculated in Geometry 00874 * 00875 * Revision 1.15 2003/03/10 18:19:54 dueffert 00876 * assignments replaced with initializations 00877 * 00878 * Revision 1.14 2003/02/20 15:31:52 dueffert 00879 * docu added 00880 * 00881 * Revision 1.13 2003/01/19 11:38:07 juengel 00882 * int versions of clipLineWithQuadrangle and isPointInsideRectangle 00883 * 00884 * Revision 1.12 2003/01/15 08:20:21 juengel 00885 * Added "int" - version of getIntersectionOfLines. 00886 * Added struct PixeledLine. 00887 * 00888 * Revision 1.11 2003/01/13 18:24:43 juengel 00889 * Comment corrected 00890 * 00891 * Revision 1.10 2002/12/16 12:03:51 dueffert 00892 * doxygen bug fixed 00893 * 00894 * Revision 1.9 2002/12/14 19:45:54 roefer 00895 * paintLinesPerceptToImageView added 00896 * 00897 * Revision 1.8 2002/12/04 12:24:35 juengel 00898 * Changed parameter "pointOnField" of method calculatePointOnField() from Vector2<double> to Vector2<int>. 00899 * 00900 * Revision 1.7 2002/12/02 12:02:10 juengel 00901 * Finished cohen sutherland line clipping. 00902 * 00903 * Revision 1.6 2002/12/01 17:37:45 juengel 00904 * Worked at clipping functions. 00905 * 00906 * Revision 1.5 2002/11/28 18:53:52 juengel 00907 * RadarViewer3D shows images projected on ground. 00908 * 00909 * Revision 1.4 2002/11/19 15:43:04 dueffert 00910 * doxygen comments corrected 00911 * 00912 * Revision 1.3 2002/09/22 18:40:52 risler 00913 * added new math functions, removed GTMath library 00914 * 00915 * Revision 1.2 2002/09/22 13:10:50 risler 00916 * new Math headers added 00917 * 00918 * Revision 1.1 2002/09/22 09:15:34 risler 00919 * Geometry.h moved to directory Math 00920 * 00921 * Revision 1.1 2002/09/10 15:53:58 cvsadm 00922 * Created new project GT2003 (M.L.) 00923 * - Cleaned up the /Src/DataTypes directory 00924 * - Removed challenge related source code 00925 * - Removed processing of incoming audio data 00926 * - Renamed AcousticMessage to SoundRequest 00927 * 00928 * Revision 1.4 2002/06/13 18:22:10 dueffert 00929 * ray intersection added 00930 * 00931 * Revision 1.3 2002/06/07 12:11:09 risler 00932 * moved max min to GTMath 00933 * 00934 * Revision 1.2 2002/05/14 12:39:04 dueffert 00935 * corrected some documentation mistakes 00936 * 00937 * Revision 1.1.1.1 2002/05/10 12:40:33 cvsadm 00938 * Moved GT2002 Project from ute to tamara. 00939 * 00940 * Revision 1.14 2002/04/25 14:50:37 kallnik 00941 * changed double/float to double 00942 * added several #include GTMath 00943 * 00944 * PLEASE use double 00945 * 00946 * Revision 1.13 2002/04/16 15:44:04 dueffert 00947 * vectorTo(Pose, Vector) added 00948 * 00949 * Revision 1.2 2002/04/11 14:20:04 dueffert 00950 * dribble skill filled 00951 * 00952 * Revision 1.12 2002/04/09 11:18:03 loetzsch 00953 * added min and max 00954 * 00955 * Revision 1.11 2002/04/08 19:53:14 juengel 00956 * Drawing of percept collections in images added. 00957 * 00958 * Revision 1.10 2002/04/06 02:30:55 loetzsch 00959 * added angleTo and distanceTo functions 00960 * 00961 * Revision 1.9 2002/04/04 18:43:31 juengel 00962 * Disatance and distance from point to line added. 00963 * 00964 * Revision 1.8 2002/03/29 14:55:48 juengel 00965 * "horizon aligned grid" started. 00966 * 00967 * Revision 1.7 2002/03/24 17:47:02 juengel 00968 * LinesPercept defined and LinesPerceptor added. 00969 * 00970 * Revision 1.6 2002/03/18 09:45:48 kallnik 00971 * GTMathTable updated 00972 * GTMathConfig updated 00973 * several doubles changed in GTMathValue 00974 * 00975 * Revision 1.5 2002/02/12 22:42:42 juengel 00976 * ImageProcessorTester improved. 00977 * 00978 * Revision 1.4 2002/02/11 00:56:36 loetzsch 00979 * added a constructor for class Circle 00980 * 00981 * Revision 1.3 2002/01/30 01:08:56 dueffert 00982 * fixed endless-compile-bug caused by up/downcase difference MathLib vs. Mathlib, makefile should be caseUNsensitive (in such cases) now 00983 * 00984 * Revision 1.2 2002/01/23 12:34:18 juengel 00985 * Kommentare eingefügt 00986 * 00987 * Revision 1.1 2002/01/22 14:54:47 juengel 00988 * Geometry eingeführt 00989 * 00990 * 00991 */