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  unsigned int x; /**< x coordinate */
36  unsigned int y; /**< y coordinate */
37 } upoint_t;
38 
39 /** Point with cartesian coordinates as signed integers. */
40 typedef struct point_struct {
41  int x; /**< x coordinate */
42  int y; /**< y coordinate */
43 
44  /** Default constructor */
46 
47  /** Constructor.
48  * @param x The x coordinate
49  * @param y The y coordinate
50  */
51  point_struct(int x, int y) {
52  this->x = x;
53  this->y = y;
54  }
55 
56 } point_t;
57 
58 /** Cartesian coordinates (2D). */
59 typedef struct cart_coord_2d_struct {
60  float x; /**< x coordinate */
61  float y; /**< y coordinate */
62 
63  /** Default constructor */
65 
66  /** Constructor.
67  * @param x The x coordinate.
68  * @param y The y coordinate.
69  */
70  cart_coord_2d_struct(float x, float y) {
71  this->x = x;
72  this->y = y;
73  }
74 
76 
77 /** Cartesian coordinates (3D). */
78 typedef struct {
79  float x; /**< x coordinate */
80  float y; /**< y coordinate */
81  float z; /**< z coordinate */
83 
84 /** Polar coordinates. */
85 typedef struct {
86  float r; /**< distance */
87  float phi; /**< angle */
89 
90 /** Polar coordinates. */
91 typedef struct {
92  float r; /**< distance */
93  float phi; /**< x-y : plane */
94  float theta; /**< plane-z : space */
96 
97 /** Rectangular extent with unsigne integers. */
98 typedef struct {
99  unsigned int w; /**< width */
100  unsigned int h; /**< height */
101 } extent_2d_t;
102 
103 /** Rectangle (unsigned integers) */
104 typedef struct {
105  upoint_t start; /**< start point */
106  extent_2d_t extent; /**< extent */
107 } rectangle_t;
108 
109 /** Position on the field. */
110 typedef struct {
111  float x; /**< x coordinate in meters */
112  float y; /**< y coordinate in meters */
113  float ori; /**< orientation */
114 } field_pos_t;
115 
116 /** Describes a field line */
117 typedef struct field_line_struct{
118  cart_coord_2d_t start; /**< start of the line [m] */
119  cart_coord_2d_t end; /**< end of the line [m] */
120 
121  /**
122  * Constructor
123  * @param start of the line
124  * @param end of the line
125  */
127  {
128  this->start = start;
129  this->end = end;
130  }
131 
132  /**
133  * Constructor
134  * @param start_x of the line
135  * @param start_y of the line
136  * @param end_x of the line
137  * @param end_y of the line
138  */
139  field_line_struct(float start_x, float start_y, float end_x, float end_y)
140  {
141  this->start.x = start_x;
142  this->start.y = start_y;
143  this->end.x = end_x;
144  this->end.y = end_y;
145  }
146 } field_line_t;
147 
148 /** Defines an arc (or circle) */
149 typedef struct arc_struct {
150  /** Constructor.
151  * @param radius The radius of the arc or circle
152  * @param center_x The x-coordinate of the center of the arc or circle
153  * @param center_y The y-coordinate of the center of the arc or circle
154  * @param start_phi The start angle of the arc
155  * @param end_phi The end angle of the arc
156  */
157  arc_struct(float radius, float center_x, float center_y, float start_phi = 0, float end_phi = M_TWO_PI) {
158  this->radius = radius;
159  this->center.x = center_x;
160  this->center.y = center_y;
161  this->start_phi = start_phi;
162  this->end_phi = end_phi;
163  }
164 
165  float radius; /**< The radius of the arc or circle */
166  cart_coord_2d_t center; /**< The center of the arc or circle */
167  float start_phi; /**< The start angle of the arc */
168  float end_phi; /**< The end angle of the arc */
169 } arc_t;
170 
171 /** Defines an ellipse */
172 typedef struct ellipse_struct {
173  cart_coord_2d_t center; /**< The center point of the ellipse */
174  float width; /**< The total width of the ellipse */
175  float height; /**< The total height of the ellipse */
176 
177  /** Constructur.
178  * @param x The x-coordinate of the center of the ellipse
179  * @param y The y-coordinate of the center of the ellipse
180  * @param w The total width of the ellipse
181  * @param h The total height of the ellipse
182  */
183  ellipse_struct(float x, float y, float w, float h) {
184  this->center.x = x;
185  this->center.y = y;
186  this->width = w;
187  this->height = h;
188  }
189 
190 } ellipse_t;
191 
192 /** Defines a point with 6-degrees of freedom */
193 typedef struct point_6D_struct {
194  float x; /**< The x-coordinate of the point */
195  float y; /**< The y-coordinate of the point */
196  float z; /**< The z-coordinate of the point */
197  float roll; /**< The angle around the x-axis */
198  float pitch; /**< The angle around the y-axis */
199  float yaw; /**< The angle around the z-axis */
200 } point_6D_t;
201 
202 } // end namespace fawkes
203 
204 #endif
Polar coordinates.
Definition: types.h:91
struct fawkes::point_struct point_t
Point with cartesian coordinates as signed integers.
Definition: astar.h:43
float phi
x-y : plane
Definition: types.h:93
float height
The total height of the ellipse.
Definition: types.h:175
float x
x coordinate
Definition: types.h:79
cart_coord_2d_t center
The center point of the ellipse.
Definition: types.h:173
Describes a field line.
Definition: types.h:117
ellipse_struct(float x, float y, float w, float h)
Constructur.
Definition: types.h:183
point_struct(int x, int y)
Constructor.
Definition: types.h:51
Cartesian coordinates (2D).
Definition: types.h:59
Fawkes library namespace.
float y
y coordinate
Definition: types.h:80
struct fawkes::ellipse_struct ellipse_t
Defines an ellipse.
unsigned int y
y coordinate
Definition: types.h:36
Defines an ellipse.
Definition: types.h:172
cart_coord_2d_t end
end of the line [m]
Definition: types.h:119
unsigned int x
x coordinate
Definition: types.h:35
float theta
plane-z : space
Definition: types.h:94
cart_coord_2d_t start
start of the line [m]
Definition: types.h:118
float r
distance
Definition: types.h:92
unsigned int h
height
Definition: types.h:100
float x
The x-coordinate of the point.
Definition: types.h:194
Rectangle (unsigned integers)
Definition: types.h:104
Polar coordinates.
Definition: types.h:85
upoint_t start
start point
Definition: types.h:105
Defines a point with 6-degrees of freedom.
Definition: types.h:193
float z
The z-coordinate of the point.
Definition: types.h:196
cart_coord_2d_struct(float x, float y)
Constructor.
Definition: types.h:70
field_line_struct(fawkes::cart_coord_2d_t start, fawkes::cart_coord_2d_t end)
Constructor.
Definition: types.h:126
cart_coord_2d_struct()
Default constructor.
Definition: types.h:64
struct fawkes::point_6D_struct point_6D_t
Defines a point with 6-degrees of freedom.
float start_phi
The start angle of the arc.
Definition: types.h:167
unsigned int w
width
Definition: types.h:99
float x
x coordinate in meters
Definition: types.h:111
float pitch
The angle around the y-axis.
Definition: types.h:198
float y
The y-coordinate of the point.
Definition: types.h:195
Defines an arc (or circle)
Definition: types.h:149
float z
z coordinate
Definition: types.h:81
Position on the field.
Definition: types.h:110
Rectangular extent with unsigne integers.
Definition: types.h:98
int y
y coordinate
Definition: types.h:42
struct fawkes::arc_struct arc_t
Defines an arc (or circle)
struct fawkes::cart_coord_2d_struct cart_coord_2d_t
Cartesian coordinates (2D).
Point with cartesian coordinates as unsigned integers.
Definition: types.h:34
Cartesian coordinates (3D).
Definition: types.h:78
extent_2d_t extent
extent
Definition: types.h:106
float y
y coordinate
Definition: types.h:61
float end_phi
The end angle of the arc.
Definition: types.h:168
cart_coord_2d_t center
The center of the arc or circle.
Definition: types.h:166
float r
distance
Definition: types.h:86
field_line_struct(float start_x, float start_y, float end_x, float end_y)
Constructor.
Definition: types.h:139
struct fawkes::field_line_struct field_line_t
Describes a field line.
point_struct()
Default constructor.
Definition: types.h:45
Point with cartesian coordinates as signed integers.
Definition: types.h:40
float roll
The angle around the x-axis.
Definition: types.h:197
float radius
The radius of the arc or circle.
Definition: types.h:165
float phi
angle
Definition: types.h:87
float yaw
The angle around the z-axis.
Definition: types.h:199
float ori
orientation
Definition: types.h:113
float y
y coordinate in meters
Definition: types.h:112
float width
The total width of the ellipse.
Definition: types.h:174
arc_struct(float radius, float center_x, float center_y, float start_phi=0, float end_phi=M_TWO_PI)
Constructor.
Definition: types.h:157
int x
x coordinate
Definition: types.h:41
float x
x coordinate
Definition: types.h:60