⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 main.h

📁 浙江大学 RoboCup3D 2006 源代码
💻 H
📖 第 1 页 / 共 2 页
字号:
/*************************************************************************** *   Copyright (C) 2004 - 2006 by ZJUBase                                  *
 *                                National Lab of Industrial Control Tech. * *                                Zhejiang University, China               *
*                                                                         * *   Team members:                                                         *
 *    Currently the team leader is,                                        * *           Hao JIANG (jianghao@iipc.zju.edu.cn; riveria@gmail.com)       *
 *    In the next season, the leader will be                               * *           Yifeng ZHANG (yfzhang@iipc.zju.edu.cn)                        *
 *    ZJUBase 3D agent is created by                                       * *           Dijun LUO (djluo@iipc.zju.edu.cn)                             *
 *    All the members who has ever contributed:                            * *           Jun JIANG                                                     *
 *           Xinfeng DU (xfdu@iipc.zju.edu.cn)                             *
 *           Yang ZHOU (yzhou@iipc.zju.edu.cn)                             *
 *           Zhipeng YANG                                                  *
 *           Xiang FAN                                                     *
 *                                                                         *
 *   Team Manager:                                                          *
 *      Ms. Rong XIONG (rxiong@iipc.zju.edu.cn)                            *
 *                                                                         *
 *   If you met any problems or you have something to discuss about        * *   ZJUBase. Please feel free to contact us through EMails given below.   * *                                                                         * *   This program is free software; you can redistribute it and/or modify  * *   it under the terms of the GNU General Public License as published by  * *   the Free Software Foundation; either version 2 of the License, or     * *   (at your option) any later version.                                   * *                                                                         * *   This program is distributed in the hope that it will be useful,       * *   but WITHOUT ANY WARRANTY; without even the implied warranty of        * *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         * *   GNU General Public License for more details.                          * *                                                                         * *   You should have received a copy of the GNU General Public License     * *   along with this program; if not, write to the                         * *   Free Software Foundation, Inc.,                                       * *   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             * ***************************************************************************/
#ifndef mainH
#define mainH
//---------------------------------------------------------------------------
#include <Classes.hpp>
#include <Controls.hpp>
#include <StdCtrls.hpp>
#include <Forms.hpp>
#include <Buttons.hpp>
#include <Dialogs.hpp>
#include <ComCtrls.hpp>
#include <NMUDP.hpp>
#include <ImgList.hpp>
#include <ToolWin.hpp>
#include <ExtCtrls.hpp>
#include <ScktComp.hpp>
#include <vector>
#include "stdio.h"
#include <string>
#include "math.h"
#define PI 3.1415926
#include "monitor.h"

#define LOG_NUM_LINE 55

using namespace std;
typedef struct tagstrWM{
    char str[LOG_NUM_LINE][120];
}MyWM;
typedef vector<MyWM> vecWM;
typedef double Angle;

enum CoordSystemT {
  CARTESIAN,
  POLAR
};
//=======================
double cosDeg  ( Angle x             );
double sinDeg  ( Angle x             );
double tanDeg  ( Angle x             );
Angle atanDeg ( double x             );
double atan2Deg( double x,  double y  );
Angle acosDeg ( double x             );
Angle asinDeg ( double x             );
Angle Rad2Deg ( double x             );
double Deg2Rad ( Angle x             );
//=======================

class Monitor;

class VecPosition
{
  // private member data
private:


  // public methods
public:
  double m_x;   /*!< x-coordinate of this position */
  double m_y;   /*!< y-coordinate of this position */
  // constructor for VecPosition class
  VecPosition                               ( double            vx = 0,
                                              double            vy = 0,
                                              CoordSystemT      cs = CARTESIAN);

  // overloaded arithmetic operators
  VecPosition        operator -             (                                 );
  VecPosition        operator +             ( const double      &d            );
  VecPosition        operator +             ( const VecPosition &p            );
  VecPosition        operator -             ( const double      &d            );
  VecPosition        operator -             ( const VecPosition &p            );
  VecPosition        operator *             ( const double      &d            );
  VecPosition        operator *             ( const VecPosition &p            );
  VecPosition        operator /             ( const double      &d            );
  VecPosition        operator /             ( const VecPosition &p            );
  void               operator =             ( const double      &d            );
  void               operator +=            ( const VecPosition &p            );
  void               operator +=            ( const double      &d            );
  void               operator -=            ( const VecPosition &p            );
  void               operator -=            ( const double      &d            );
  void               operator *=            ( const VecPosition &p            );
  void               operator *=            ( const double      &d            );
  void               operator /=            ( const VecPosition &p            );
  void               operator /=            ( const double      &d            );
  bool               operator !=            ( const VecPosition &p            );
  bool               operator !=            ( const double      &d            );
  bool               operator ==            ( const VecPosition &p            );
  bool               operator ==            ( const double      &d            );

  // methods for producing output
  friend ostream&    operator <<            ( ostream           &os,
                                              VecPosition       &p             );
  void               show                   ( CoordSystemT      cs = CARTESIAN);
  string             str                    ( CoordSystemT      cs = CARTESIAN);

  // set- and get methods for private member variables
  bool               setX                   ( double            dX            );
  double             getX                   (                           ) const;
  bool               setY                   ( double            dY            );
  double             getY                   (                           ) const;

  // set- and get methods for derived position information
  void               setVecPosition         ( double            dX = 0,
                                              double            dY = 0,
                                              CoordSystemT      cs = CARTESIAN);
  double             getDistanceTo          ( const VecPosition p             );
  VecPosition        setMagnitude           ( double            d             );
  double             getMagnitude           (                           ) const;
  Angle             getDirection           (                           ) const;

  //gyj add
  Angle 	getDirectionTo(const VecPosition &p);
  void		rand(double r);
  //gyj end

  // comparison methods for positions
  bool               isInFrontOf            ( const VecPosition &p            );
  bool               isInFrontOf            ( const double      &d            );
  bool               isBehindOf             ( const VecPosition &p            );
  bool               isBehindOf             ( const double      &d            );
  bool               isLeftOf               ( const VecPosition &p            );
  bool               isLeftOf               ( const double      &d            );
  bool               isRightOf              ( const VecPosition &p            );
  bool               isRightOf              ( const double      &d            );
  bool               isBetweenX             ( const VecPosition &p1,
                                              const VecPosition &p2           );
  bool               isBetweenX             ( const double      &d1,
                                              const double      &d2           );
  bool               isBetweenY             ( const VecPosition &p1,
                                              const VecPosition &p2           );
  bool               isBetweenY             ( const double      &d1,
                                              const double      &d2           );

  // conversion methods for positions
  VecPosition        normalize              (                                 );
  VecPosition        rotate                 ( Angle            angle         );
  VecPosition        globalToRelative       ( VecPosition       orig,
                                              Angle            ang           );
  VecPosition        relativeToGlobal       ( VecPosition       orig,
                                              Angle            ang           );
  VecPosition        getVecPositionOnLineFraction( VecPosition  &p,
                                              double            dFrac         );

  // static class methods
  static VecPosition getVecPositionFromPolar( double            dMag,
                                              Angle            ang           );
  static Angle      normalizeAngle         ( Angle            angle         );
  bool isInField(double margine);
};


class Vector {
public:
  double x;
  double y;

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -