april
1.0.0
...
All
Classes
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Macros
Pages
abox2d.h
Go to the documentation of this file.
1
/* ========================================================================= */
2
/* ------------------------------------------------------------------------- */
/*
12
13
14
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
15
Please read COPYING and README files in root folder
16
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
17
*/
18
/* ------------------------------------------------------------------------- */
19
/* ========================================================================= */
20
#ifndef __ABOX2D_INC__
21
#define __ABOX2D_INC__
22
//
23
//
24
//
25
//
26
/* INCLUDES ------------------------------------------------------------ */
27
28
#include "
p2d.h
"
29
30
/* INCLUDES ============================================================ */
31
//
32
//
33
//
34
//
35
/* CLASS --------------------------------------------------------------- */
36
43
struct
ABOX2D
{
44
45
//
46
//
47
//
48
//
49
/* DEFINITIONS ----------------------------------------------------- */
50
51
/* DEFINITIONS ===================================================== */
52
//
53
//
54
//
55
//
56
/* DATA ------------------------------------------------------------ */
57
58
union
{
62
COORDV
pts_
[4];
63
64
65
struct
{
66
67
71
COORDV
left_
;
72
73
77
COORDV
bottom_
;
78
79
83
COORDV
right_
;
84
85
89
COORDV
top_
;
90
91
};
92
93
94
struct
{
95
96
100
P2D
bottom_left_
;
101
102
106
P2D
top_right_
;
107
108
};
109
110
};
111
/* DATA ============================================================ */
112
//
113
//
114
//
115
//
116
/* FUNCTIONS ------------------------------------------------------- */
117
118
public
:
119
123
inline
void
reset
(
void
)
124
{
bottom_left_
.
reset
();
top_right_
.
reset
(); }
125
126
132
inline
bool
operator ==
(
const
ABOX2D
& other )
const
133
{
134
return
( (
COORDV_EQ
(
pts_
[0], other.
pts_
[0] ) ) &&
135
(
COORDV_EQ
(
pts_
[1], other.
pts_
[1] ) ) &&
136
(
COORDV_EQ
(
pts_
[2], other.
pts_
[2] ) ) &&
137
(
COORDV_EQ
(
pts_
[3], other.
pts_
[3] ) )
138
);
139
}
140
141
145
inline
bool
operator !=
(
const
ABOX2D
& other )
const
146
{
147
return
!( *
this
== other );
148
}
149
150
154
inline
void
operator +=
(
const
ABOX2D
& other )
155
{
156
unite
( other );
157
}
158
159
163
inline
void
operator -=
(
const
ABOX2D
& other )
164
{
165
intersect
( other );
166
}
167
168
172
inline
COORDV
width
(
void
)
const
173
{
return
right_
-
left_
; }
174
175
179
inline
COORDV
height
(
void
)
const
180
{
return
top_
-
bottom_
; }
181
182
189
inline
bool
isDegenerate
(
void
)
const
190
{
return
( (
width
() > 0 ) && (
height
() > 0 ) ); }
191
192
196
inline
COORDV
diagonal
(
void
)
const
197
{
return
width
() *
height
(); }
198
199
203
void
unite
(
204
const
ABOX2D
& first,
205
const
ABOX2D
& second
206
);
207
208
212
void
unite
(
213
const
ABOX2D
& other
214
);
215
216
224
bool
contains
(
225
const
P2D
& other
226
)
const
;
227
228
235
bool
contains
(
236
const
ABOX2D
& other
237
)
const
;
238
239
245
bool
intersect
(
246
const
ABOX2D
& first,
247
const
ABOX2D
& second
248
);
249
250
257
bool
intersect
(
258
const
ABOX2D
& other
259
);
260
264
inline
bool
isNormalised
(
void
)
const
265
{
return
( (
left_
<=
right_
) && (
bottom_
<=
top_
) ); }
266
267
271
void
normalise
(
void
);
272
278
void
offset
(
COORDV
dist );
279
280
286
void
offset
(
COORDV
dist,
ABOX2D
& out )
const
;
287
288
292
void
translate
(
293
COORDV
dx,
294
COORDV
dy
295
)
296
{
297
left_
+= dx;
298
bottom_
+= dy;
299
right_
+= dx;
300
top_
+= dy;
301
}
302
303
309
bool
visibleIn
(
310
const
ABOX2D
& other
311
)
const
;
312
313
317
inline
COORDV
area
(
void
)
318
{
return
width
() *
height
(); }
319
320
324
inline
void
center
(
P2D
& c )
325
{
326
c.
x_
= (
left_
+
right_
) / 2;
327
c.
y_
= (
bottom_
+
top_
) / 2;
328
}
329
330
331
/* FUNCTIONS ======================================================= */
332
//
333
//
334
//
335
//
336
337
};
/* class ABOX2D */
338
339
/* CLASS =============================================================== */
340
//
341
//
342
//
343
//
344
#endif // __ABOX2D_INC__
345
/* ------------------------------------------------------------------------- */
346
/* ========================================================================= */
april
gui
geometry
abox2d.h
Generated on Sat Apr 20 2013 16:35:29 for april by
1.8.1.2