BoundingBox2D Class Reference

#include <BoundingBox2D.h>

List of all members.

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)


Constructor & Destructor Documentation

BoundingBox2D::BoundingBox2D (  ) 

00026 {}

BoundingBox2D::BoundingBox2D ( Vector2D  tl,
Vector2D  br 
)

00029 {
00030     this->tl = tl;
00031     this->br = br;
00032 }

BoundingBox2D::BoundingBox2D ( double  tlx,
double  tly,
double  brx,
double  bry 
)

00035 {
00036     tl.x = tlx;
00037     tl.y = tly;
00038     br.x = brx;
00039     br.y = bry;
00040 }

BoundingBox2D::BoundingBox2D ( Vector2D  center,
double  width 
)

00043 {
00044     tl.x = center.x - width * 0.5;
00045     tl.y = center.y + width * 0.5;
00046     br.x = center.x + width * 0.5;
00047     br.y = center.y - width * 0.5;
00048 }


Member Function Documentation

bool BoundingBox2D::collide ( const BoundingBox2D  box  )  const

00051 {
00052     if(tl.x > box.br.x)
00053         return false;
00054     if(tl.y < box.br.y)
00055         return false;
00056 
00057     if(br.x < box.tl.x)
00058         return false;
00059     if(br.y > box.tl.y)
00060         return false;
00061 
00062     return true;
00063 }

bool BoundingBox2D::collide ( const Vector2D  p  )  const

00066 {
00067     if(p.x > tl.x && p.x < br.x && p.y < tl.y && p.y > br.y)
00068         return true;
00069     else
00070         return false;
00071 }

double BoundingBox2D::top (  ) 

00074 {
00075     return tl.y;
00076 }

double BoundingBox2D::bottom (  ) 

00079 {
00080     return br.y;
00081 }

double BoundingBox2D::left (  ) 

00084 {
00085     return tl.x;
00086 }

double BoundingBox2D::right (  ) 

00089 {
00090     return br.x;
00091 }


Friends And Related Function Documentation

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

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


Member Data Documentation


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

Generated on Fri Sep 19 13:05:06 2008 for ITM OverSim by  doxygen 1.5.5