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. */
00040 typedef struct {
00041   float x;      /**< x coordinate */
00042   float y;      /**< y coordinate */
00043 } cart_coord_2d_t;
00044 
00045 /** Polar coordinates. */
00046 typedef struct {
00047   float r;      /**< distance */
00048   float phi;    /**< angle */
00049 } polar_coord_2d_t;
00050 
00051 /** Rectangular extent with unsigne integers. */
00052 typedef struct {
00053   unsigned int w;       /**< width */
00054   unsigned int h;       /**< height */
00055 } extent_2d_t;
00056 
00057 /** Rectangle (unsigned integers) */
00058 typedef struct {
00059   point_t      start;      /**< start point */
00060   extent_2d_t  extent;     /**< extent */
00061 } rectangle_t;
00062 
00063 /** Position on the field. */
00064 typedef struct {
00065   float x;      /**< x coordinate in meters */
00066   float y;      /**< y coordinate in meters */
00067   float ori;    /**< orientation */
00068 } field_pos_t;
00069 
00070 /** Describes a field line */
00071 typedef struct field_line_struct{
00072   cart_coord_2d_t start;   /**< start of the line [m] */
00073   cart_coord_2d_t end;     /**< end of the line [m] */
00074 
00075   /**
00076    * Constructor
00077    * @param start of the line
00078    * @param end of the line
00079    */
00080   field_line_struct(fawkes::cart_coord_2d_t start, fawkes::cart_coord_2d_t end)
00081   {
00082     this->start = start;
00083     this->end   = end;
00084   }
00085 
00086   /**
00087    * Constructor
00088    * @param start_x of the line
00089    * @param start_y of the line
00090    * @param end_x of the line
00091    * @param end_y of the line
00092    */
00093   field_line_struct(float start_x, float start_y, float end_x, float end_y)
00094   {
00095     this->start.x = start_x;
00096     this->start.y = start_y;
00097     this->end.x   = end_x;
00098     this->end.y   = end_y;
00099   }
00100 } field_line_t;
00101 
00102 /** Defines an arc (or circle) */
00103 typedef struct arc_struct {
00104   /** Constructor.
00105    * @param radius The radius of the arc or circle
00106    * @param center_x The x-coordinate of the center of the arc or circle
00107    * @param center_y The y-coordinate of the center of the arc or circle
00108    * @param start_phi The start angle of the arc
00109    * @param end_phi The end angle of the arc
00110    */
00111   arc_struct(float radius, float center_x, float center_y, float start_phi = 0, float end_phi = M_TWO_PI) {
00112     this->radius    = radius;
00113     this->center.x  = center_x;
00114     this->center.y  = center_y;
00115     this->start_phi = start_phi;
00116     this->end_phi   = end_phi;
00117   }
00118 
00119   float radius;           /**< The radius of the arc or circle */
00120   cart_coord_2d_t center; /**< The center of the arc or circle */
00121   float start_phi;        /**< The start angle of the arc */
00122   float end_phi;          /**< The end angle of the arc */
00123 } arc_t;
00124 
00125 /** Defines a point with 6-degrees of freedom */
00126 typedef struct point_6D_struct {
00127   float x;      /**< The x-coordinate of the point */
00128   float y;      /**< The y-coordinate of the point */
00129   float z;      /**< The z-coordinate of the point */
00130   float roll;   /**< The angle around the x-axis */
00131   float pitch;  /**< The angle around the y-axis */
00132   float yaw;    /**< The angle around the z-axis */
00133 } point_6D_t;
00134 
00135 } // end namespace fawkes
00136 
00137 #endif