Fawkes API  Fawkes Development Version
types.h
00001 
00002 /***************************************************************************
00003  *  types.h - Simple math related types
00004  *
00005  *  Created: Thu Oct 30 14:32:38 2008
00006  *  Copyright  2008  Tim Niemueller [www.niemueller.de]
00007  *
00008  ****************************************************************************/
00009 
00010 /*  This program is free software; you can redistribute it and/or modify
00011  *  it under the terms of the GNU General Public License as published by
00012  *  the Free Software Foundation; either version 2 of the License, or
00013  *  (at your option) any later version. A runtime exception applies to
00014  *  this software (see LICENSE.GPL_WRE file mentioned below for details).
00015  *
00016  *  This program is distributed in the hope that it will be useful,
00017  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
00018  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00019  *  GNU Library General Public License for more details.
00020  *
00021  *  Read the full text in the LICENSE.GPL_WRE file in the doc directory.
00022  */
00023 
00024 #ifndef __UTILS_MATH_TYPES_H_
00025 #define __UTILS_MATH_TYPES_H_
00026 
00027 #ifndef M_TWO_PI
00028 #define M_TWO_PI 6.28318530717959
00029 #endif
00030 
00031 namespace fawkes {
00032 
00033 /** Point with cartesian coordinates as unsigned integers. */
00034 typedef struct {
00035   unsigned int x;       /**< x coordinate */
00036   unsigned int y;       /**< y coordinate */
00037 } point_t;
00038 
00039 /** Cartesian coordinates (2D). */
00040 typedef struct {
00041   float x;      /**< x coordinate */
00042   float y;      /**< y coordinate */
00043 } cart_coord_2d_t;
00044 
00045 /** Cartesian coordinates (3D). */
00046 typedef struct {
00047   float x;      /**< x coordinate */
00048   float y;      /**< y coordinate */
00049   float z;      /**< z coordinate */
00050 } cart_coord_3d_t;
00051 
00052 /** Polar coordinates. */
00053 typedef struct {
00054   float r;      /**< distance */
00055   float phi;    /**< angle */
00056 } polar_coord_2d_t;
00057 
00058 /** Rectangular extent with unsigne integers. */
00059 typedef struct {
00060   unsigned int w;       /**< width */
00061   unsigned int h;       /**< height */
00062 } extent_2d_t;
00063 
00064 /** Rectangle (unsigned integers) */
00065 typedef struct {
00066   point_t      start;      /**< start point */
00067   extent_2d_t  extent;     /**< extent */
00068 } rectangle_t;
00069 
00070 /** Position on the field. */
00071 typedef struct {
00072   float x;      /**< x coordinate in meters */
00073   float y;      /**< y coordinate in meters */
00074   float ori;    /**< orientation */
00075 } field_pos_t;
00076 
00077 /** Describes a field line */
00078 typedef struct field_line_struct{
00079   cart_coord_2d_t start;   /**< start of the line [m] */
00080   cart_coord_2d_t end;     /**< end of the line [m] */
00081 
00082   /**
00083    * Constructor
00084    * @param start of the line
00085    * @param end of the line
00086    */
00087   field_line_struct(fawkes::cart_coord_2d_t start, fawkes::cart_coord_2d_t end)
00088   {
00089     this->start = start;
00090     this->end   = end;
00091   }
00092 
00093   /**
00094    * Constructor
00095    * @param start_x of the line
00096    * @param start_y of the line
00097    * @param end_x of the line
00098    * @param end_y of the line
00099    */
00100   field_line_struct(float start_x, float start_y, float end_x, float end_y)
00101   {
00102     this->start.x = start_x;
00103     this->start.y = start_y;
00104     this->end.x   = end_x;
00105     this->end.y   = end_y;
00106   }
00107 } field_line_t;
00108 
00109 /** Defines an arc (or circle) */
00110 typedef struct arc_struct {
00111   /** Constructor.
00112    * @param radius The radius of the arc or circle
00113    * @param center_x The x-coordinate of the center of the arc or circle
00114    * @param center_y The y-coordinate of the center of the arc or circle
00115    * @param start_phi The start angle of the arc
00116    * @param end_phi The end angle of the arc
00117    */
00118   arc_struct(float radius, float center_x, float center_y, float start_phi = 0, float end_phi = M_TWO_PI) {
00119     this->radius    = radius;
00120     this->center.x  = center_x;
00121     this->center.y  = center_y;
00122     this->start_phi = start_phi;
00123     this->end_phi   = end_phi;
00124   }
00125 
00126   float radius;           /**< The radius of the arc or circle */
00127   cart_coord_2d_t center; /**< The center of the arc or circle */
00128   float start_phi;        /**< The start angle of the arc */
00129   float end_phi;          /**< The end angle of the arc */
00130 } arc_t;
00131 
00132 /** Defines a point with 6-degrees of freedom */
00133 typedef struct point_6D_struct {
00134   float x;      /**< The x-coordinate of the point */
00135   float y;      /**< The y-coordinate of the point */
00136   float z;      /**< The z-coordinate of the point */
00137   float roll;   /**< The angle around the x-axis */
00138   float pitch;  /**< The angle around the y-axis */
00139   float yaw;    /**< The angle around the z-axis */
00140 } point_6D_t;
00141 
00142 } // end namespace fawkes
00143 
00144 #endif