OverSim
BoundingBox2D Class Reference

BoundingBox2D class. More...

#include <BoundingBox2D.h>

Public Member Functions

 BoundingBox2D ()
 BoundingBox2D (Vector2D tl, Vector2D br)
 BoundingBox2D (double tlx, double tly, double brx, double bry)
 BoundingBox2D (Vector2D center, double width)
bool collide (const BoundingBox2D box) const
bool collide (const Vector2D p) const
double top ()
double bottom ()
double left ()
double right ()

Public Attributes

Vector2D tl
Vector2D br

Friends

std::ostream & operator<< (std::ostream &Stream, const BoundingBox2D &box)

Detailed Description

BoundingBox2D class.

axies aligned two dimensional bounding box

Definition at line 34 of file BoundingBox2D.h.

Constructor & Destructor Documentation

BoundingBox2D::BoundingBox2D ( )

Definition at line 26 of file BoundingBox2D.cc.

{}
BoundingBox2D::BoundingBox2D ( Vector2D  tl,
Vector2D  br 
)

Definition at line 28 of file BoundingBox2D.cc.

{
this->tl = tl;
this->br = br;
}
BoundingBox2D::BoundingBox2D ( double  tlx,
double  tly,
double  brx,
double  bry 
)

Definition at line 34 of file BoundingBox2D.cc.

{
tl.x = tlx;
tl.y = tly;
br.x = brx;
br.y = bry;
}
BoundingBox2D::BoundingBox2D ( Vector2D  center,
double  width 
)

Definition at line 42 of file BoundingBox2D.cc.

{
tl.x = center.x - width * 0.5;
tl.y = center.y + width * 0.5;
br.x = center.x + width * 0.5;
br.y = center.y - width * 0.5;
}

Member Function Documentation

double BoundingBox2D::bottom ( )

Definition at line 78 of file BoundingBox2D.cc.

{
return br.y;
}
bool BoundingBox2D::collide ( const BoundingBox2D  box) const

Definition at line 50 of file BoundingBox2D.cc.

{
if(tl.x > box.br.x)
return false;
if(tl.y < box.br.y)
return false;
if(br.x < box.tl.x)
return false;
if(br.y > box.tl.y)
return false;
return true;
}
bool BoundingBox2D::collide ( const Vector2D  p) const

Definition at line 65 of file BoundingBox2D.cc.

{
if(p.x > tl.x && p.x < br.x && p.y < tl.y && p.y > br.y)
return true;
else
return false;
}
double BoundingBox2D::left ( )

Definition at line 83 of file BoundingBox2D.cc.

{
return tl.x;
}
double BoundingBox2D::right ( )

Definition at line 88 of file BoundingBox2D.cc.

{
return br.x;
}
double BoundingBox2D::top ( )

Definition at line 73 of file BoundingBox2D.cc.

{
return tl.y;
}

Friends And Related Function Documentation

std::ostream& operator<< ( std::ostream &  Stream,
const BoundingBox2D box 
)
friend

Definition at line 93 of file BoundingBox2D.cc.

{
return Stream << box.tl << " - " << box.br;
}

Member Data Documentation

Vector2D BoundingBox2D::br

Definition at line 47 of file BoundingBox2D.h.

Referenced by bottom(), BoundingBox2D(), collide(), operator<<(), and right().

Vector2D BoundingBox2D::tl

Definition at line 47 of file BoundingBox2D.h.

Referenced by BoundingBox2D(), collide(), left(), operator<<(), and top().


The documentation for this class was generated from the following files: