00001 /*************************************************************************** 00002 * Copyright (C) 2005-2011 LpzRobots development team * 00003 * Georg Martius <georg dot martius at web dot de> * 00004 * Frank Guettler <guettler at informatik dot uni-leipzig dot de * 00005 * Frank Hesse <frank at nld dot ds dot mpg dot de> * 00006 * Ralf Der <ralfder at mis dot mpg dot de> * 00007 * * 00008 * This program is free software; you can redistribute it and/or modify * 00009 * it under the terms of the GNU General Public License as published by * 00010 * the Free Software Foundation; either version 2 of the License, or * 00011 * (at your option) any later version. * 00012 * * 00013 * This program is distributed in the hope that it will be useful, * 00014 * but WITHOUT ANY WARRANTY; without even the implied warranty of * 00015 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * 00016 * GNU General Public License for more details. * 00017 * * 00018 * You should have received a copy of the GNU General Public License * 00019 * along with this program; if not, write to the * 00020 * Free Software Foundation, Inc., * 00021 * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * 00022 * * 00023 ***************************************************************************/ 00024 #ifndef __DEGREESEGMENT_H 00025 #define __DEGREESEGMENT_H 00026 00027 #include "abstracttracksection.h" 00028 00029 /** 00030 * class for degree segments 00031 */ 00032 class DegreeSegment : public AbstractTrackSection { 00033 00034 public: 00035 00036 /** 00037 * Constructor 00038 */ 00039 DegreeSegment(const Position& p,const double& angle); 00040 00041 00042 /** 00043 * Constructor 00044 */ 00045 DegreeSegment(const Matrix& position); 00046 00047 virtual ~DegreeSegment(){} 00048 00049 00050 /** 00051 * returns the length of the segment, 00052 * here it is the length of the arc 00053 */ 00054 00055 virtual double getLength(); 00056 00057 /** 00058 * returns the width of the segment, 00059 */ 00060 virtual double getWidth(); 00061 00062 /** 00063 * sets the width of the segment, 00064 */ 00065 virtual void setWidth(double w); 00066 00067 00068 virtual void setCurveAngle(const double& alpha); 00069 00070 virtual void setRadius(const double& rad); 00071 00072 /** 00073 * gives the position and rotation(angle) of the segment at the 00074 * end of the segment so that a new segment could be placed there 00075 * if you want to place the new segment, you must muliplicate: 00076 * getTransformedEndMatrix()*getPositionMatrix(); 00077 */ 00078 virtual Matrix getTransformedEndMatrix(); 00079 00080 00081 /** 00082 * returns true if the real coordinates lay inside of the segment 00083 */ 00084 virtual bool isInside(const Position& p); 00085 00086 00087 /** 00088 * returns a value between 0 and 100 that tells at which section 00089 * you are on the segment. 00090 * 0 means you are on the beginning 00091 * 100 means you are at the end 00092 * returns -1 if no IdValue can be given 00093 */ 00094 virtual double getSectionIdValue(const Position& p); 00095 00096 00097 /** 00098 * returns a value between 0 and 100 that tells at which width 00099 * you are on the segment, more to right or more to the left. 00100 * 0 means you are on the left 00101 * 50 means you are in the middle 00102 * 100 means you are on the right 00103 * returns -1 if no WidthValue can be given 00104 */ 00105 virtual double getWidthIdValue(const Position& p); 00106 00107 00108 /** 00109 * draws the obstacle (4 boxes for the playground) 00110 */ 00111 virtual void draw(); 00112 00113 00114 00115 virtual void create(dSpaceID space); 00116 00117 00118 virtual void destroy(); 00119 00120 protected: 00121 // this is the radius of the curve 00122 double radius; 00123 // this is the width of the segment 00124 // normally it should be the same like alle the other segments 00125 double width; 00126 00127 bool show_aabb; 00128 00129 // the wall to be drawed 00130 list<dGeomID> innerWalls; 00131 list<dGeomID> outerWalls; 00132 00133 double widthWall; 00134 double heightWall; 00135 00136 // angle is for 90DegreeSegment is 90 00137 double angle; 00138 00139 // determines if the curve goes left or right 00140 int left; 00141 00142 bool obstacle_exists; 00143 00144 /** 00145 * obstacle color 00146 */ 00147 Color color; 00148 00149 void setProperties(); 00150 00151 /** 00152 * returns the local coordinates on the track at the given radius and angle 00153 that are responsible for the segment of the 00154 */ 00155 Position getLocalCoordinates(double radius, double alpha); 00156 00157 /** 00158 * returns the global coordinates on the track at the given radius and angle 00159 that are responsible for the segment of the 00160 */ 00161 Position getGlobalCoordinates(double radius, double alpha); 00162 00163 }; 00164 00165 #endif 00166 00167 00168