QPRBoundingBox Class Reference

#include <QuonPRDefs.h>

List of all members.


Detailed Description

Definition at line 38 of file QuonPRDefs.h.


Public Member Functions

 QPRBoundingBox ()
 QPRBoundingBox (Vector2D tl, Vector2D br)
 QPRBoundingBox (double tlx, double tly, double brx, double bry)
 QPRBoundingBox (Vector2D center, double width)
void resize (double width)
bool collide (const QPRBoundingBox box) const
bool collide (const Vector2D p) const
int getChildNum (const Vector2D p) const
QPRBoundingBox getQuadrant (int i) const
Vector2D shiftCenter (PRDirection direction) const

Public Attributes

Vector2D tl
Vector2D br
Vector2D center

Friends

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

Constructor & Destructor Documentation

QPRBoundingBox::QPRBoundingBox (  ) 

Definition at line 26 of file QuonPRDefs.cc.

Referenced by getQuadrant().

00026 {}

QPRBoundingBox::QPRBoundingBox ( Vector2D  tl,
Vector2D  br 
)

Definition at line 28 of file QuonPRDefs.cc.

00029 {
00030     this->tl = tl;
00031     this->br = br;
00032     center = (tl + br) * 0.5;
00033 }

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

Definition at line 35 of file QuonPRDefs.cc.

00036 {
00037     tl.x = tlx;
00038     tl.y = tly;
00039     br.x = brx;
00040     br.y = bry;
00041     center = (tl + br) * 0.5;
00042 }

QPRBoundingBox::QPRBoundingBox ( Vector2D  center,
double  width 
)

Definition at line 44 of file QuonPRDefs.cc.

00045 {
00046     this->center = center;
00047     tl.x = center.x - width * 0.5;
00048     tl.y = center.y + width * 0.5;
00049     br.x = center.x + width * 0.5;
00050     br.y = center.y - width * 0.5;
00051 }


Member Function Documentation

void QPRBoundingBox::resize ( double  width  ) 

Definition at line 53 of file QuonPRDefs.cc.

00054 {
00055     width /= 2.0;
00056     tl.x = center.x - width;
00057     tl.y = center.y + width;
00058     br.x = center.x + width;
00059     br.y = center.y - width;
00060 }

bool QPRBoundingBox::collide ( const QPRBoundingBox  box  )  const

Definition at line 63 of file QuonPRDefs.cc.

Referenced by QuonPR::classifySites(), PRTreeNode::findBindingNeighbor(), and QuonPR::updateThisSite().

00064 {
00065     if(tl.x > box.br.x) {
00066         return false;
00067     }
00068     if(tl.y < box.br.y) {
00069         return false;
00070     }
00071     if(br.x < box.tl.x) {
00072         return false;
00073     }
00074     if(br.y > box.tl.y) {
00075         return false;
00076     }
00077 
00078     return true;
00079 }

bool QPRBoundingBox::collide ( const Vector2D  p  )  const

Definition at line 81 of file QuonPRDefs.cc.

00082 {
00083     if(p.x > tl.x && p.x < br.x && p.y < tl.y && p.y > br.y) {
00084         return true;
00085     }
00086     else {
00087         return false;
00088     }
00089 }

int QPRBoundingBox::getChildNum ( const Vector2D  p  )  const

Definition at line 91 of file QuonPRDefs.cc.

Referenced by PRTreeNode::add(), PRTreeNode::findBindingNeighbor(), PRTreeNode::getDepth(), and PRTreeNode::remove().

00092 {
00093     int childnum;
00094     if(p.x > center.x) {
00095         if(p.y < center.y) {
00096             childnum = 2;
00097         }
00098         else {
00099             childnum = 1;
00100         }
00101     }
00102     else {
00103         if(p.y < center.y) {
00104             childnum = 3;
00105         }
00106         else {
00107             childnum = 0;
00108         }
00109     }
00110     return childnum;
00111 }

QPRBoundingBox QPRBoundingBox::getQuadrant ( int  i  )  const

Definition at line 113 of file QuonPRDefs.cc.

Referenced by PRTreeNode::add(), and PRTreeNode::findBindingNeighbor().

00114 {
00115     Vector2D quadTl = tl;
00116     Vector2D quadBr = center;
00117     double width = center.x - tl.x;
00118     if(i == 1 || i == 2) {
00119         quadTl.x += width;
00120         quadBr.x += width;
00121     }
00122     if(i == 2 || i == 3) {
00123         quadTl.y -= width;
00124         quadBr.y -= width;
00125     }
00126 
00127     return QPRBoundingBox(quadTl, quadBr);
00128 }

Vector2D QPRBoundingBox::shiftCenter ( PRDirection  direction  )  const

Definition at line 130 of file QuonPRDefs.cc.

Referenced by QuonPR::classifySites(), and PRTreeNode::findBindingNeighbor().

00131 {
00132     Vector2D temp = center;
00133     double width = br.x - tl.x;
00134     switch(direction) {
00135         case NW:
00136             temp.x -= width;
00137             temp.y += width;
00138         break;
00139         case N:
00140             temp.y += width;
00141         break;
00142         case NE:
00143             temp.x += width;
00144             temp.y += width;
00145         break;
00146         case E:
00147             temp.x += width;
00148         break;
00149         case SE:
00150             temp.x += width;
00151             temp.y -= width;
00152         break;
00153         case S:
00154             temp.y -= width;
00155         break;
00156         case SW:
00157             temp.x -= width;
00158             temp.y -= width;
00159         break;
00160         case W:
00161             temp.x -= width;
00162         break;
00163     }
00164     return temp;
00165 }


Friends And Related Function Documentation

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

Definition at line 167 of file QuonPRDefs.cc.

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


Member Data Documentation

Definition at line 51 of file QuonPRDefs.h.

Referenced by collide(), getQuadrant(), operator<<(), QPRBoundingBox(), resize(), and shiftCenter().

Definition at line 51 of file QuonPRDefs.h.

Referenced by collide(), operator<<(), QPRBoundingBox(), resize(), and shiftCenter().


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

Generated on Wed Mar 25 16:32:54 2009 for OverSim by  doxygen 1.5.5