46 return ((left () >= right ()) || (top () <= bottom ()));
50 return bot_left == other.bot_left && top_right == other.top_right;
54 return top_right.y ();
75 return top_right.x ();
86 return ICOORD (top_right.x (), bot_left.y ());
90 return ICOORD (bot_left.x (), top_right.y ());
99 return top_right.y () - bot_left.y ();
106 return top_right.x () - bot_left.x ();
113 return width () * height ();
120 void pad(
int xpad,
int ypad) {
126 void move_bottom_edge(
128 bot_left +=
ICOORD (0, y);
133 bot_left +=
ICOORD (x, 0);
136 void move_right_edge(
138 top_right +=
ICOORD (x, 0);
143 top_right +=
ICOORD (0, y);
154 bot_left.
set_x ((
inT16) floor (bot_left.x () + vec.
x ()));
156 bot_left.set_y ((
inT16) floor (bot_left.y () + vec.
y ()));
158 top_right.set_x ((
inT16) ceil (top_right.x () + vec.
x ()));
160 top_right.set_y ((
inT16) ceil (top_right.y () + vec.
y ()));
166 bot_left.set_x ((
inT16) floor (bot_left.x () *
f));
167 bot_left.set_y ((
inT16) floor (bot_left.y () *
f));
168 top_right.set_x ((
inT16) ceil (top_right.x () *
f));
169 top_right.set_y ((
inT16) ceil (top_right.y () *
f));
173 bot_left.set_x ((
inT16) floor (bot_left.x () * vec.
x ()));
174 bot_left.set_y ((
inT16) floor (bot_left.y () * vec.
y ()));
175 top_right.set_x ((
inT16) ceil (top_right.x () * vec.
x ()));
176 top_right.set_y ((
inT16) ceil (top_right.y () * vec.
y ()));
183 bot_left.rotate (vec);
184 top_right.rotate (vec);
185 *
this =
TBOX (bot_left, top_right);
190 void rotate_large(
const FCOORD& vec);
196 const TBOX &box)
const;
199 const TBOX &box)
const;
202 const TBOX &box)
const;
205 bool x_overlap(
const TBOX &box)
const;
211 return MAX(bot_left.x(), box.bot_left.
x()) -
212 MIN(top_right.x(), box.top_right.
x());
219 return MAX(bot_left.y(), box.bot_left.
y()) -
220 MIN(top_right.y(), box.top_right.
y());
225 bool major_x_overlap(
const TBOX &box)
const;
228 bool y_overlap(
const TBOX &box)
const;
232 bool major_y_overlap(
const TBOX &box)
const;
235 double overlap_fraction(
const TBOX &box)
const;
238 double x_overlap_fraction(
const TBOX& box)
const;
241 double y_overlap_fraction(
const TBOX& box)
const;
244 bool x_almost_equal(
const TBOX &box,
int tolerance)
const;
247 bool almost_equal(
const TBOX &box,
int tolerance)
const;
250 const TBOX &box)
const;
253 const TBOX &box)
const;
257 bot_left.set_x(x_min);
258 bot_left.set_y(y_min);
259 top_right.set_x(x_max);
260 top_right.set_y(y_max);
264 tprintf(
"Bounding box=(%d,%d)->(%d,%d)\n",
265 left(), bottom(), right(), top());
272 sprintf(buffer,
"Bounding box=(%d,%d)->(%d,%d)\n",
273 left(), bottom(), right(), top());
277 #ifndef GRAPHICS_DISABLED
280 fd->
Rectangle(bot_left.x (), bot_left.y (), top_right.x (),
290 bool Serialize(FILE* fp)
const;
293 bool DeSerialize(
bool swap, FILE* fp);
324 return ((pt.
x () >= bot_left.
x ()) &&
325 (pt.
x () <= top_right.
x ()) &&
326 (pt.
y () >= bot_left.
y ()) && (pt.
y () <= top_right.
y ()));
346 const TBOX &box)
const {
347 return ((box.bot_left.
x () <= top_right.
x ()) &&
348 (box.top_right.
x () >= bot_left.
x ()) &&
349 (box.bot_left.
y () <= top_right.
y ()) &&
350 (box.top_right.
y () >= bot_left.
y ()));
359 const TBOX &box)
const {
361 overlap -=
MAX(box.bot_left.
x(), bot_left.
x());
365 overlap =
MIN(box.top_right.
y(), top_right.
y());
366 overlap -=
MAX(box.bot_left.
y(), bot_left.
y());
379 double fraction = 0.0;
392 return ((box.bot_left.
x() <= top_right.
x()) &&
393 (box.top_right.
x() >= bot_left.
x()));
405 overlap -= this->
left() - box.
left();
410 return (overlap >= box.
width() / 2 || overlap >= this->
width() / 2);
419 return ((box.bot_left.
y() <= top_right.
y()) &&
420 (box.top_right.
y() >= bot_left.
y()));
434 if (this->
top() < box.
top()) {
435 overlap -= box.
top() - this->
top();
437 return (overlap >= box.
height() / 2 || overlap >= this->
height() / 2);
453 if (other.
left() <= x && x <= other.
right())
458 return MAX(0, static_cast<double>(high - low) / width);
475 if (other.
bottom() <= y && y <= other.
top())
480 return MAX(0, static_cast<double>(high - low) / height);