-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgeometry.h
165 lines (130 loc) · 3.9 KB
/
geometry.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
//========================================================================
// This software is free: you can redistribute it and/or modify
// it under the terms of the GNU General Public License Version 3,
// as published by the Free Software Foundation.
//
// This software is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// Version 3 in the file COPYING that came with this distribution.
// If not, see <http://www.gnu.org/licenses/>.
//========================================================================
/*!
\file geometry.h
\brief Meta-header to include all significant geometry-related classes
\author James R. Bruce <[email protected]>, (C) 2007
\author Stefan Zickler, (C) 2008
*/
//========================================================================
#ifndef __GEOMETRY_H__
#define __GEOMETRY_H__
#define USE_QUATERIONS 1
#define USE_MATRIX_FIXED_SIZE 0
#define USE_POSE 1
//==== Vector types ====//
#include "gvector.h"
#include "geomalgo.h"
typedef GVector::vector2d<double> vector2d;
typedef GVector::vector3d<double> vector3d;
typedef GVector::vector2d<float> vector2f;
typedef GVector::vector3d<float> vector3f;
typedef GVector::vector2d<int> vector2i;
typedef GVector::vector3d<int> vector3i;
struct vector2s{
int16_t x,y;
};
struct vector3s{
int16_t x,y,z;
};
//==== Bounding boxes ====//
#include "bbox.h"
typedef BBox::BBox2D<vector2d,double> BBox2d;
typedef BBox::BBox3D<vector3d,double> BBox3d;
typedef BBox::BBox2D<vector2f,float> BBox2f;
typedef BBox::BBox3D<vector3f,float> BBox3f;
//==== Range Type ====//
#include "range.h"
typedef Range::Range<float ,false,true> RangeFloat;
typedef Range::Range<double,false,true> RangeDouble;
typedef Range::Range<int ,false,true> RangeInt;
typedef Range::Range<float ,false,false> ClosedRangeFloat;
typedef Range::Range<double,false,false> ClosedRangeDouble;
typedef Range::Range<int ,false,false> ClosedRangeInt;
//==== Angle and matrix types ====//
#if USE_QUATERIONS
#include "quaternion.h"
typedef Quaternion<double> quat;
typedef Quaternion<float> quatf;
#endif
#if USE_MATRIX_FIXED_SIZE
#include "matrix_fixed.h"
typedef Mat3x3<double> mat3x3d;
typedef Mat3x3<float> mat3x3f;
#endif
//==== Other geometric types ====//
#if USE_POSE
#include "pose.h"
typedef DynamicPose2D<vector2f,float > DPose2f;
typedef DynamicPose2D<vector2d,double> DPose2d;
#endif
//==== Some vector conversion functions ====//
template <class vector_a,class vector_b>
void vcopy2d(vector_a &dest,const vector_b &src)
{
dest.x = src.x;
dest.y = src.y;
}
template <class vector_a,class vector_b>
void vcopy3d(vector_a &dest,const vector_b &src)
{
dest.x = src.x;
dest.y = src.y;
dest.z = src.z;
}
template <class vec_in>
inline vector2f vec2f(const vec_in &p)
{
return(vector2f(p.x,p.y));
}
template <class vec_in>
inline vector2d vec2d(const vec_in &p)
{
return(vector2d(p.x,p.y));
}
template <class vec_in>
inline vector3f vec3f(const vec_in &p)
{
return(vector3f(p.x,p.y,p.z));
}
template <class vec_in>
inline vector3d vec3d(const vec_in &p)
{
return(vector3d(p.x,p.y,p.z));
}
template <class vec_in>
inline vector2s vec2s(const vec_in &p)
{
vector2s vs;
vs.x = (int)rint(p.x);
vs.y = (int)rint(p.y);
return(vs);
}
template <class vec_in>
inline vector3s vec3s(const vec_in &p)
{
vector3s vs;
vs.x = (int)rint(p.x);
vs.y = (int)rint(p.y);
vs.z = (int)rint(p.z);
return(vs);
}
//==== Angle conversion, and normally missing constant(s) ====//
#define RAD(deg) ((deg) * (M_PI / 180.0)) /* convert radians to degrees */
#define DEG(rad) ((rad) * (180.0 / M_PI)) /* convert degrees to radians */
#ifndef HUGE_VALF
#define HUGE_VALF (1E37)
#endif
#endif // __GEOMETRY_H__