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 } point_t;
38 
39 /** Cartesian coordinates (2D). */
40 typedef struct {
41  float x; /**< x coordinate */
42  float y; /**< y coordinate */
44 
45 /** Cartesian coordinates (3D). */
46 typedef struct {
47  float x; /**< x coordinate */
48  float y; /**< y coordinate */
49  float z; /**< z coordinate */
51 
52 /** Polar coordinates. */
53 typedef struct {
54  float r; /**< distance */
55  float phi; /**< angle */
57 
58 /** Rectangular extent with unsigne integers. */
59 typedef struct {
60  unsigned int w; /**< width */
61  unsigned int h; /**< height */
62 } extent_2d_t;
63 
64 /** Rectangle (unsigned integers) */
65 typedef struct {
66  point_t start; /**< start point */
67  extent_2d_t extent; /**< extent */
68 } rectangle_t;
69 
70 /** Position on the field. */
71 typedef struct {
72  float x; /**< x coordinate in meters */
73  float y; /**< y coordinate in meters */
74  float ori; /**< orientation */
75 } field_pos_t;
76 
77 /** Describes a field line */
78 typedef struct field_line_struct{
79  cart_coord_2d_t start; /**< start of the line [m] */
80  cart_coord_2d_t end; /**< end of the line [m] */
81 
82  /**
83  * Constructor
84  * @param start of the line
85  * @param end of the line
86  */
88  {
89  this->start = start;
90  this->end = end;
91  }
92 
93  /**
94  * Constructor
95  * @param start_x of the line
96  * @param start_y of the line
97  * @param end_x of the line
98  * @param end_y of the line
99  */
100  field_line_struct(float start_x, float start_y, float end_x, float end_y)
101  {
102  this->start.x = start_x;
103  this->start.y = start_y;
104  this->end.x = end_x;
105  this->end.y = end_y;
106  }
107 } field_line_t;
108 
109 /** Defines an arc (or circle) */
110 typedef struct arc_struct {
111  /** Constructor.
112  * @param radius The radius of the arc or circle
113  * @param center_x The x-coordinate of the center of the arc or circle
114  * @param center_y The y-coordinate of the center of the arc or circle
115  * @param start_phi The start angle of the arc
116  * @param end_phi The end angle of the arc
117  */
118  arc_struct(float radius, float center_x, float center_y, float start_phi = 0, float end_phi = M_TWO_PI) {
119  this->radius = radius;
120  this->center.x = center_x;
121  this->center.y = center_y;
122  this->start_phi = start_phi;
123  this->end_phi = end_phi;
124  }
125 
126  float radius; /**< The radius of the arc or circle */
127  cart_coord_2d_t center; /**< The center of the arc or circle */
128  float start_phi; /**< The start angle of the arc */
129  float end_phi; /**< The end angle of the arc */
130 } arc_t;
131 
132 /** Defines a point with 6-degrees of freedom */
133 typedef struct point_6D_struct {
134  float x; /**< The x-coordinate of the point */
135  float y; /**< The y-coordinate of the point */
136  float z; /**< The z-coordinate of the point */
137  float roll; /**< The angle around the x-axis */
138  float pitch; /**< The angle around the y-axis */
139  float yaw; /**< The angle around the z-axis */
140 } point_6D_t;
141 
142 } // end namespace fawkes
143 
144 #endif
Cartesian coordinates (2D).
Definition: types.h:40
float x
x coordinate
Definition: types.h:47
Describes a field line.
Definition: types.h:78
Fawkes library namespace.
float y
y coordinate
Definition: types.h:48
unsigned int x
x coordinate
Definition: types.h:35
float y
y coordinate
Definition: types.h:42
cart_coord_2d_t end
end of the line [m]
Definition: types.h:80
cart_coord_2d_t start
start of the line [m]
Definition: types.h:79
unsigned int h
height
Definition: types.h:61
float x
The x-coordinate of the point.
Definition: types.h:134
Rectangle (unsigned integers)
Definition: types.h:65
Polar coordinates.
Definition: types.h:53
Defines a point with 6-degrees of freedom.
Definition: types.h:133
float z
The z-coordinate of the point.
Definition: types.h:136
Point with cartesian coordinates as unsigned integers.
Definition: types.h:34
field_line_struct(fawkes::cart_coord_2d_t start, fawkes::cart_coord_2d_t end)
Constructor.
Definition: types.h:87
point_t start
start point
Definition: types.h:66
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:128
unsigned int w
width
Definition: types.h:60
float x
x coordinate in meters
Definition: types.h:72
float pitch
The angle around the y-axis.
Definition: types.h:138
float y
The y-coordinate of the point.
Definition: types.h:135
Defines an arc (or circle)
Definition: types.h:110
unsigned int y
y coordinate
Definition: types.h:36
float z
z coordinate
Definition: types.h:49
Position on the field.
Definition: types.h:71
Rectangular extent with unsigne integers.
Definition: types.h:59
struct fawkes::arc_struct arc_t
Defines an arc (or circle)
Cartesian coordinates (3D).
Definition: types.h:46
extent_2d_t extent
extent
Definition: types.h:67
float end_phi
The end angle of the arc.
Definition: types.h:129
cart_coord_2d_t center
The center of the arc or circle.
Definition: types.h:127
float r
distance
Definition: types.h:54
field_line_struct(float start_x, float start_y, float end_x, float end_y)
Constructor.
Definition: types.h:100
struct fawkes::field_line_struct field_line_t
Describes a field line.
float roll
The angle around the x-axis.
Definition: types.h:137
float radius
The radius of the arc or circle.
Definition: types.h:126
float phi
angle
Definition: types.h:55
float yaw
The angle around the z-axis.
Definition: types.h:139
float ori
orientation
Definition: types.h:74
float y
y coordinate in meters
Definition: types.h:73
float x
x coordinate
Definition: types.h:41
arc_struct(float radius, float center_x, float center_y, float start_phi=0, float end_phi=M_TWO_PI)
Constructor.
Definition: types.h:118