proj home

Files   Classes   Functions   Hierarchy  

boxcollision.h

Go to the documentation of this file.
00001 #ifndef BOXCOLLISION_H
00002 #define BOXCOLLISION_H
00003 
00004 #include <cassert>
00005 using namespace std;
00006 
00007 #include <particle.h>
00008 #include <typedefs.h>
00009 
00018 class boxcollision
00019 {
00020 public:
00021 
00022   // Define bounding box.
00024   double x0;
00026   double x1;
00028   double y0;
00030   double y1;
00031 
00033   boxcollision
00034   (
00035     doublec x0_, 
00036     doublec x1_, 
00037     doublec y0_, 
00038     doublec y1_
00039   )
00040     : x0(x0_), x1(x1_), y0(y0_), y1(y1_) {}
00041 
00044   boolc left  ( particle & p, doublec h ) const;
00047   boolc right ( particle & p, doublec h ) const;
00050   boolc up    ( particle & p, doublec h ) const;
00053   boolc down  ( particle & p, doublec h ) const;
00054 
00056   boolc walls ( particle & p, doublec h ) const
00057   {
00058     if (left(p,h))
00059       return true;
00060     if (right(p,h))
00061       return true;
00062     if (up(p,h))
00063       return true;
00064     if (down(p,h))
00065       return true;
00066 
00067     return false;
00068   }
00069 
00071   ostream & print(ostream & os) const 
00072     { os << "x0=" << x0 << " x1=" << x1;
00073       return os << " y0=" << y0 << " y1=" << y1; }
00074 
00075 };
00076 
00077 ostream & operator <<
00078 (
00079   ostream & os,
00080   boxcollision const & b
00081 );
00082 //{ return b.print(os); }
00083 
00084 
00085 
00086 
00087 
00088 
00089 
00090 
00091 #endif
00092 
00093 

Generated on Fri Mar 4 00:49:29 2011 for Chelton Evans Source by  doxygen 1.5.8