Fawkes API  Fawkes Development Version
types.h
1 
2 /***************************************************************************
3  * types.h - Simple math related types
4  *
5  * Created: Thu Oct 30 14:32:38 2008
6  * Copyright 2008 Tim Niemueller [www.niemueller.de]
7  *
8  ****************************************************************************/
9 
10 /* This program is free software; you can redistribute it and/or modify
11  * it under the terms of the GNU General Public License as published by
12  * the Free Software Foundation; either version 2 of the License, or
13  * (at your option) any later version. A runtime exception applies to
14  * this software (see LICENSE.GPL_WRE file mentioned below for details).
15  *
16  * This program is distributed in the hope that it will be useful,
17  * but WITHOUT ANY WARRANTY; without even the implied warranty of
18  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19  * GNU Library General Public License for more details.
20  *
21  * Read the full text in the LICENSE.GPL_WRE file in the doc directory.
22  */
23 
24 #ifndef _UTILS_MATH_TYPES_H_
25 #define _UTILS_MATH_TYPES_H_
26 
27 #ifndef M_TWO_PI
28 # define M_TWO_PI 6.28318530717959
29 #endif
30 
31 namespace fawkes {
32 
33 /** Point with cartesian coordinates as unsigned integers. */
34 typedef struct
35 {
36  unsigned int x; /**< x coordinate */
37  unsigned int y; /**< y coordinate */
38 } upoint_t;
39 
40 /** Point with cartesian coordinates as signed integers. */
41 typedef struct point_struct
42 {
43  int x; /**< x coordinate */
44  int y; /**< y coordinate */
45 
46  /** Default constructor */
48  {
49  }
50 
51  /** Constructor.
52  * @param x The x coordinate
53  * @param y The y coordinate
54  */
55  point_struct(int x, int y)
56  {
57  this->x = x;
58  this->y = y;
59  }
60 
61 } point_t;
62 
63 /** Cartesian coordinates (2D). */
64 typedef struct cart_coord_2d_struct
65 {
66  float x; /**< x coordinate */
67  float y; /**< y coordinate */
68 
69  /** Default constructor */
71  {
72  }
73 
74  /** Constructor.
75  * @param x The x coordinate.
76  * @param y The y coordinate.
77  */
78  cart_coord_2d_struct(float x, float y)
79  {
80  this->x = x;
81  this->y = y;
82  }
83 
85 
86 /** Cartesian coordinates (3D). */
87 typedef struct
88 {
89  float x; /**< x coordinate */
90  float y; /**< y coordinate */
91  float z; /**< z coordinate */
93 
94 /** Polar coordinates. */
95 typedef struct
96 {
97  float r; /**< distance */
98  float phi; /**< angle */
100 
101 /** Polar coordinates. */
102 typedef struct
103 {
104  float r; /**< distance */
105  float phi; /**< x-y : plane */
106  float theta; /**< plane-z : space */
108 
109 /** Rectangular extent with unsigne integers. */
110 typedef struct
111 {
112  unsigned int w; /**< width */
113  unsigned int h; /**< height */
114 } extent_2d_t;
115 
116 /** Rectangle (unsigned integers) */
117 typedef struct
118 {
119  upoint_t start; /**< start point */
120  extent_2d_t extent; /**< extent */
121 } rectangle_t;
122 
123 /** Position on the field. */
124 typedef struct
125 {
126  float x; /**< x coordinate in meters */
127  float y; /**< y coordinate in meters */
128  float ori; /**< orientation */
129 } field_pos_t;
130 
131 /** Describes a field line */
132 typedef struct field_line_struct
133 {
134  cart_coord_2d_t start; /**< start of the line [m] */
135  cart_coord_2d_t end; /**< end of the line [m] */
136 
137  /**
138  * Constructor
139  * @param start of the line
140  * @param end of the line
141  */
143  {
144  this->start = start;
145  this->end = end;
146  }
147 
148  /**
149  * Constructor
150  * @param start_x of the line
151  * @param start_y of the line
152  * @param end_x of the line
153  * @param end_y of the line
154  */
155  field_line_struct(float start_x, float start_y, float end_x, float end_y)
156  {
157  this->start.x = start_x;
158  this->start.y = start_y;
159  this->end.x = end_x;
160  this->end.y = end_y;
161  }
162 } field_line_t;
163 
164 /** Defines an arc (or circle) */
165 typedef struct arc_struct
166 {
167  /** Constructor.
168  * @param radius The radius of the arc or circle
169  * @param center_x The x-coordinate of the center of the arc or circle
170  * @param center_y The y-coordinate of the center of the arc or circle
171  * @param start_phi The start angle of the arc
172  * @param end_phi The end angle of the arc
173  */
175  float center_x,
176  float center_y,
177  float start_phi = 0,
178  float end_phi = M_TWO_PI)
179  {
180  this->radius = radius;
181  this->center.x = center_x;
182  this->center.y = center_y;
183  this->start_phi = start_phi;
184  this->end_phi = end_phi;
185  }
186 
187  float radius; /**< The radius of the arc or circle */
188  cart_coord_2d_t center; /**< The center of the arc or circle */
189  float start_phi; /**< The start angle of the arc */
190  float end_phi; /**< The end angle of the arc */
191 } arc_t;
192 
193 /** Defines an ellipse */
194 typedef struct ellipse_struct
195 {
196  cart_coord_2d_t center; /**< The center point of the ellipse */
197  float width; /**< The total width of the ellipse */
198  float height; /**< The total height of the ellipse */
199 
200  /** Constructur.
201  * @param x The x-coordinate of the center of the ellipse
202  * @param y The y-coordinate of the center of the ellipse
203  * @param w The total width of the ellipse
204  * @param h The total height of the ellipse
205  */
206  ellipse_struct(float x, float y, float w, float h)
207  {
208  this->center.x = x;
209  this->center.y = y;
210  this->width = w;
211  this->height = h;
212  }
213 
214 } ellipse_t;
215 
216 /** Defines a point with 6-degrees of freedom */
217 typedef struct point_6D_struct
218 {
219  float x; /**< The x-coordinate of the point */
220  float y; /**< The y-coordinate of the point */
221  float z; /**< The z-coordinate of the point */
222  float roll; /**< The angle around the x-axis */
223  float pitch; /**< The angle around the y-axis */
224  float yaw; /**< The angle around the z-axis */
225 } point_6D_t;
226 
227 } // end namespace fawkes
228 
229 #endif
fawkes::ellipse_struct::center
cart_coord_2d_t center
The center point of the ellipse.
Definition: types.h:196
fawkes::cart_coord_3d_t::y
float y
y coordinate
Definition: types.h:90
fawkes::arc_struct
Defines an arc (or circle)
Definition: types.h:165
fawkes::point_struct
Point with cartesian coordinates as signed integers.
Definition: types.h:41
fawkes::polar_coord_3d_t::phi
float phi
x-y : plane
Definition: types.h:105
fawkes::field_line_struct
Describes a field line.
Definition: types.h:132
fawkes::arc_struct::start_phi
float start_phi
The start angle of the arc.
Definition: types.h:189
fawkes::cart_coord_2d_struct::cart_coord_2d_struct
cart_coord_2d_struct(float x, float y)
Constructor.
Definition: types.h:78
fawkes::polar_coord_2d_t::r
float r
distance
Definition: types.h:97
fawkes::cart_coord_2d_struct::cart_coord_2d_struct
cart_coord_2d_struct()
Default constructor.
Definition: types.h:70
fawkes::field_pos_t
Position on the field.
Definition: types.h:124
fawkes::polar_coord_2d_t
Polar coordinates.
Definition: types.h:95
fawkes::arc_struct::end_phi
float end_phi
The end angle of the arc.
Definition: types.h:190
fawkes::upoint_t
Point with cartesian coordinates as unsigned integers.
Definition: types.h:34
fawkes::arc_t
struct fawkes::arc_struct arc_t
Defines an arc (or circle)
fawkes::extent_2d_t::h
unsigned int h
height
Definition: types.h:113
fawkes::field_line_struct::field_line_struct
field_line_struct(float start_x, float start_y, float end_x, float end_y)
Constructor.
Definition: types.h:155
fawkes::cart_coord_3d_t
Cartesian coordinates (3D).
Definition: types.h:87
fawkes::polar_coord_3d_t::theta
float theta
plane-z : space
Definition: types.h:106
fawkes::field_line_struct::start
cart_coord_2d_t start
start of the line [m]
Definition: types.h:134
fawkes::point_6D_struct::roll
float roll
The angle around the x-axis.
Definition: types.h:222
fawkes::point_6D_t
struct fawkes::point_6D_struct point_6D_t
Defines a point with 6-degrees of freedom.
fawkes::point_struct::point_struct
point_struct()
Default constructor.
Definition: types.h:47
fawkes::cart_coord_2d_struct::y
float y
y coordinate
Definition: types.h:67
fawkes::point_struct::point_struct
point_struct(int x, int y)
Constructor.
Definition: types.h:55
fawkes::rectangle_t::start
upoint_t start
start point
Definition: types.h:119
fawkes::point_t
struct fawkes::point_struct point_t
Point with cartesian coordinates as signed integers.
Definition: astar.h:45
fawkes::point_6D_struct::yaw
float yaw
The angle around the z-axis.
Definition: types.h:224
fawkes::extent_2d_t::w
unsigned int w
width
Definition: types.h:112
fawkes::field_line_struct::end
cart_coord_2d_t end
end of the line [m]
Definition: types.h:135
fawkes::cart_coord_2d_t
struct fawkes::cart_coord_2d_struct cart_coord_2d_t
Cartesian coordinates (2D).
fawkes::field_line_struct::field_line_struct
field_line_struct(fawkes::cart_coord_2d_t start, fawkes::cart_coord_2d_t end)
Constructor.
Definition: types.h:142
fawkes::field_pos_t::y
float y
y coordinate in meters
Definition: types.h:127
fawkes::cart_coord_3d_t::z
float z
z coordinate
Definition: types.h:91
fawkes
fawkes::upoint_t::y
unsigned int y
y coordinate
Definition: types.h:37
fawkes::ellipse_struct::ellipse_struct
ellipse_struct(float x, float y, float w, float h)
Constructur.
Definition: types.h:206
fawkes::field_pos_t::x
float x
x coordinate in meters
Definition: types.h:126
fawkes::ellipse_struct
Defines an ellipse.
Definition: types.h:194
fawkes::arc_struct::arc_struct
arc_struct(float radius, float center_x, float center_y, float start_phi=0, float end_phi=M_TWO_PI)
Constructor.
Definition: types.h:174
fawkes::rectangle_t::extent
extent_2d_t extent
extent
Definition: types.h:120
fawkes::ellipse_struct::height
float height
The total height of the ellipse.
Definition: types.h:198
fawkes::ellipse_t
struct fawkes::ellipse_struct ellipse_t
Defines an ellipse.
fawkes::polar_coord_3d_t::r
float r
distance
Definition: types.h:104
fawkes::field_line_t
struct fawkes::field_line_struct field_line_t
Describes a field line.
fawkes::cart_coord_2d_struct
Cartesian coordinates (2D).
Definition: types.h:64
fawkes::cart_coord_2d_struct::x
float x
x coordinate
Definition: types.h:66
fawkes::point_struct::y
int y
y coordinate
Definition: types.h:44
fawkes::arc_struct::radius
float radius
The radius of the arc or circle.
Definition: types.h:187
fawkes::polar_coord_3d_t
Polar coordinates.
Definition: types.h:102
fawkes::ellipse_struct::width
float width
The total width of the ellipse.
Definition: types.h:197
fawkes::rectangle_t
Rectangle (unsigned integers)
Definition: types.h:117
fawkes::arc_struct::center
cart_coord_2d_t center
The center of the arc or circle.
Definition: types.h:188
fawkes::extent_2d_t
Rectangular extent with unsigne integers.
Definition: types.h:110
fawkes::upoint_t::x
unsigned int x
x coordinate
Definition: types.h:36
fawkes::point_struct::x
int x
x coordinate
Definition: types.h:43
fawkes::field_pos_t::ori
float ori
orientation
Definition: types.h:128
fawkes::point_6D_struct::pitch
float pitch
The angle around the y-axis.
Definition: types.h:223
fawkes::point_6D_struct::y
float y
The y-coordinate of the point.
Definition: types.h:220
fawkes::cart_coord_3d_t::x
float x
x coordinate
Definition: types.h:89
fawkes::polar_coord_2d_t::phi
float phi
angle
Definition: types.h:98
fawkes::point_6D_struct
Defines a point with 6-degrees of freedom.
Definition: types.h:217
fawkes::point_6D_struct::z
float z
The z-coordinate of the point.
Definition: types.h:221
fawkes::point_6D_struct::x
float x
The x-coordinate of the point.
Definition: types.h:219