global_object.h

説明を見る。
00001 // -*-c++-*-
00002 
00008 /*
00009  *Copyright:
00010 
00011  Copyright (C) Hidehisa AKIYAMA
00012 
00013  This code is free software; you can redistribute it and/or
00014  modify it under the terms of the GNU Lesser General Public
00015  License as published by the Free Software Foundation; either
00016  version 2.1 of the License, or (at your option) any later version.
00017 
00018  This library is distributed in the hope that it will be useful,
00019  but WITHOUT ANY WARRANTY; without even the implied warranty of
00020  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00021  Lesser General Public License for more details.
00022 
00023  You should have received a copy of the GNU Lesser General Public
00024  License along with this library; if not, write to the Free Software
00025  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00026 
00027  *EndCopyright:
00028  */
00029 
00031 
00032 #ifndef RCSC_COACH_GLOBAL_OBJECT_H
00033 #define RCSC_COACH_GLOBAL_OBJECT_H
00034 
00035 #include <rcsc/geom/vector_2d.h>
00036 #include <rcsc/types.h>
00037 
00038 #include <list>
00039 #include <vector>
00040 #include <iostream>
00041 
00042 namespace rcsc {
00043 
00048 class GlobalBallObject {
00049 private:
00050 
00051     Vector2D M_pos; 
00052     Vector2D M_vel; 
00053 
00054 public:
00055 
00059     GlobalBallObject()
00060         : M_pos( 0.0, 0.0 )
00061         , M_vel( 0.0, 0.0 )
00062       { }
00063 
00068     const
00069     Vector2D & pos() const
00070       {
00071           return M_pos;
00072       }
00073 
00078     const
00079     Vector2D & vel() const
00080       {
00081           return M_vel;
00082       }
00083 
00089     void setPos( const double & x,
00090                  const double & y )
00091       {
00092           M_pos.assign( x, y );
00093       }
00094 
00100     void setVel( const double & vx,
00101                  const double & vy )
00102       {
00103           M_vel.assign( vx, vy );
00104       }
00105 };
00106 
00107 
00108 /*-------------------------------------------------------------------*/
00109 
00114 class GlobalPlayerObject {
00115 private:
00116 
00117     SideID M_side; 
00118     int M_unum; 
00119     bool M_goalie; 
00120     int M_type; 
00121 
00122     Vector2D M_pos; 
00123     Vector2D M_vel; 
00124 
00125     AngleDeg M_body; 
00126     AngleDeg M_face; 
00127 
00128     int M_pointto_cycle; //< if player is pointing, this value in incremented
00129     AngleDeg M_pointto_angle; 
00130 
00131     int M_tackle_cycle; 
00132 
00133 public:
00134 
00138     GlobalPlayerObject()
00139         : M_side( NEUTRAL )
00140         , M_unum( -1 )
00141         , M_goalie( false )
00142         , M_type( Hetero_Unknown )
00143         , M_pos( Vector2D::INVALIDATED )
00144         , M_vel( 0.0, 0.0 )
00145         , M_body( 0.0 )
00146         , M_face( 0.0 )
00147         , M_pointto_cycle( 0 )
00148         , M_pointto_angle( 0.0 )
00149         , M_tackle_cycle( 0 )
00150       { }
00151 
00156     SideID side() const
00157       {
00158           return M_side;
00159       }
00160 
00165     int unum() const
00166       {
00167           return M_unum;
00168       }
00169 
00174     bool goalie() const
00175       {
00176           return M_goalie;
00177       }
00178 
00183     int type() const
00184       {
00185           return M_type;
00186       }
00187 
00192     const
00193     Vector2D & pos() const
00194       {
00195           return M_pos;
00196       }
00197 
00202     const
00203     Vector2D & vel() const
00204       {
00205           return M_vel;
00206       }
00207 
00212     const
00213     AngleDeg & body() const
00214       {
00215           return M_body;
00216       }
00217 
00222     const
00223     AngleDeg & face() const
00224       {
00225           return M_face;
00226       }
00227 
00234     int pointtoCycle() const
00235       {
00236           return M_pointto_cycle;
00237       }
00238 
00243     const
00244     AngleDeg & pointtoAngle() const
00245       {
00246           return M_pointto_angle;
00247       }
00248 
00253     bool isPointing() const
00254       {
00255           return ( M_pointto_cycle > 0 );
00256       }
00257 
00264     int tackleCycle() const
00265       {
00266           return M_tackle_cycle;
00267       }
00268 
00273     bool isTackling() const
00274       {
00275           return ( M_tackle_cycle > 0 );
00276       }
00277 
00279 
00286     void setTeam( const SideID side,
00287                   const int unum,
00288                   const bool goalie )
00289       {
00290           M_side = side;
00291           M_unum = unum;
00292           M_goalie = goalie;
00293           if ( goalie )
00294           {
00295               M_type = Hetero_Default;
00296           }
00297       }
00298 
00303     void setPlayerType( const int type )
00304       {
00305           M_type = type;
00306       }
00307 
00313     void setPos( const double & x,
00314                  const double & y )
00315       {
00316           M_pos.assign( x, y );
00317       }
00318 
00324     void setVel( const double & vx,
00325                  const double & vy )
00326       {
00327           M_vel.assign( vx, vy );
00328       }
00329 
00335     void setAngle( const double & b,
00336                    const double & n )
00337       {
00338           M_body = b;
00339           M_face = b + n;
00340       }
00341 
00346     void setArm( const double & angle )
00347       {
00348           M_pointto_cycle = 1;
00349           M_pointto_angle = angle;
00350       }
00351 
00355     void setTackle()
00356       {
00357           M_tackle_cycle = 1;
00358       }
00359 
00364     void update( const GlobalPlayerObject & p );
00365 
00371     std::ostream & print( std::ostream & os ) const;
00372 
00373 };
00374 
00375 } // namespace rcsc
00376 
00377 #endif

librcscに対してThu May 1 15:41:20 2008に生成されました。  doxygen 1.5.0