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
31namespace fawkes {
32
33/** Point with cartesian coordinates as unsigned integers. */
34typedef 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. */
41typedef 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). */
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). */
87typedef struct
88{
89 float x; /**< x coordinate */
90 float y; /**< y coordinate */
91 float z; /**< z coordinate */
93
94/** Polar coordinates. */
95typedef struct
96{
97 float r; /**< distance */
98 float phi; /**< angle */
100
101/** Polar coordinates. */
102typedef 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. */
110typedef struct
111{
112 unsigned int w; /**< width */
113 unsigned int h; /**< height */
115
116/** Rectangle (unsigned integers) */
117typedef struct
118{
119 upoint_t start; /**< start point */
120 extent_2d_t extent; /**< extent */
122
123/** Position on the field. */
124typedef struct
125{
126 float x; /**< x coordinate in meters */
127 float y; /**< y coordinate in meters */
128 float ori; /**< orientation */
130
131/** Describes a field line */
132typedef 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 }
163
164/** Defines an arc (or circle) */
165typedef 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 */
192
193/** Defines an ellipse */
194typedef 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
215
216/** Defines a point with 6-degrees of freedom */
217typedef 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 */
226
227} // end namespace fawkes
228
229#endif
Fawkes library namespace.
struct fawkes::point_struct point_t
Point with cartesian coordinates as signed integers.
Definition: astar.h:39
struct fawkes::arc_struct arc_t
Defines an arc (or circle)
struct fawkes::field_line_struct field_line_t
Describes a field line.
struct fawkes::ellipse_struct ellipse_t
Defines an ellipse.
struct fawkes::point_6D_struct point_6D_t
Defines a point with 6-degrees of freedom.
struct fawkes::cart_coord_2d_struct cart_coord_2d_t
Cartesian coordinates (2D).
Defines an arc (or circle)
Definition: types.h:166
float end_phi
The end angle of the arc.
Definition: types.h:190
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
cart_coord_2d_t center
The center of the arc or circle.
Definition: types.h:188
float radius
The radius of the arc or circle.
Definition: types.h:187
float start_phi
The start angle of the arc.
Definition: types.h:189
Cartesian coordinates (2D).
Definition: types.h:65
cart_coord_2d_struct(float x, float y)
Constructor.
Definition: types.h:78
float y
y coordinate
Definition: types.h:67
float x
x coordinate
Definition: types.h:66
cart_coord_2d_struct()
Default constructor.
Definition: types.h:70
Cartesian coordinates (3D).
Definition: types.h:88
float y
y coordinate
Definition: types.h:90
float z
z coordinate
Definition: types.h:91
float x
x coordinate
Definition: types.h:89
Defines an ellipse.
Definition: types.h:195
cart_coord_2d_t center
The center point of the ellipse.
Definition: types.h:196
float height
The total height of the ellipse.
Definition: types.h:198
ellipse_struct(float x, float y, float w, float h)
Constructur.
Definition: types.h:206
float width
The total width of the ellipse.
Definition: types.h:197
Rectangular extent with unsigne integers.
Definition: types.h:111
unsigned int w
width
Definition: types.h:112
unsigned int h
height
Definition: types.h:113
Describes a field line.
Definition: types.h:133
cart_coord_2d_t end
end of the line [m]
Definition: types.h:135
field_line_struct(float start_x, float start_y, float end_x, float end_y)
Constructor.
Definition: types.h:155
cart_coord_2d_t start
start of the line [m]
Definition: types.h:134
field_line_struct(fawkes::cart_coord_2d_t start, fawkes::cart_coord_2d_t end)
Constructor.
Definition: types.h:142
Position on the field.
Definition: types.h:125
float y
y coordinate in meters
Definition: types.h:127
float ori
orientation
Definition: types.h:128
float x
x coordinate in meters
Definition: types.h:126
Defines a point with 6-degrees of freedom.
Definition: types.h:218
float z
The z-coordinate of the point.
Definition: types.h:221
float y
The y-coordinate of the point.
Definition: types.h:220
float yaw
The angle around the z-axis.
Definition: types.h:224
float x
The x-coordinate of the point.
Definition: types.h:219
float pitch
The angle around the y-axis.
Definition: types.h:223
float roll
The angle around the x-axis.
Definition: types.h:222
Point with cartesian coordinates as signed integers.
Definition: types.h:42
point_struct(int x, int y)
Constructor.
Definition: types.h:55
int x
x coordinate
Definition: types.h:43
int y
y coordinate
Definition: types.h:44
point_struct()
Default constructor.
Definition: types.h:47
Polar coordinates.
Definition: types.h:96
float phi
angle
Definition: types.h:98
float r
distance
Definition: types.h:97
Polar coordinates.
Definition: types.h:103
float phi
x-y : plane
Definition: types.h:105
float r
distance
Definition: types.h:104
float theta
plane-z : space
Definition: types.h:106
Rectangle (unsigned integers)
Definition: types.h:118
upoint_t start
start point
Definition: types.h:119
extent_2d_t extent
extent
Definition: types.h:120
Point with cartesian coordinates as unsigned integers.
Definition: types.h:35
unsigned int x
x coordinate
Definition: types.h:36
unsigned int y
y coordinate
Definition: types.h:37