Main Page   Modules   Class Hierarchy   Compound List   File List   Compound Members   File Members   Related Pages   Examples  

math/bbox.h

Go to the documentation of this file.
00001 #ifndef MATH_BBOX_H
00002 #define MATH_BBOX_H
00003 
00004 /*
00005 
00006   GLT OpenGL C++ Toolkit (LGPL)
00007   Copyright (C) 2000-2002 Nigel Stewart  
00008 
00009   Email: nigels.com@gmail.com   
00010   WWW:   http://www.nigels.com/glt/
00011 
00012   This library is free software; you can redistribute it and/or
00013   modify it under the terms of the GNU Lesser General Public
00014   License as published by the Free Software Foundation; either
00015   version 2.1 of the License, or (at your option) any later version.
00016 
00017   This library is distributed in the hope that it will be useful,
00018   but WITHOUT ANY WARRANTY; without even the implied warranty of
00019   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00020   Lesser General Public License for more details.
00021 
00022   You should have received a copy of the GNU Lesser General Public
00023   License along with this library; if not, write to the Free Software
00024   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00025 
00026 */
00027 
00033 #include <vector>
00034 
00035 #include <math/vector3.h>
00036 
00043 class Matrix;
00044 class GltViewport;
00045 
00046 class BoundingBox
00047 {
00052     friend std::ostream &operator<<(std::ostream &os, const BoundingBox &b);
00053 
00058     friend BoundingBox sum         (const BoundingBox &a,const BoundingBox &b);
00059 
00064     friend BoundingBox intersection(const BoundingBox &a,const BoundingBox &b);
00065 
00066 public:
00068     BoundingBox();
00070     BoundingBox(const Vector &min,const Vector &max);
00071     
00072     //
00073     // Get/Set
00074     //
00075 
00077           bool &defined();
00078 
00080     const bool  defined() const;
00081 
00083           Vector &min();
00085     const Vector &min() const;
00086 
00088           Vector &max();
00090     const Vector &max() const;
00091 
00093     Vector center() const;
00094 
00096     real width() const;
00097 
00099     real height() const;
00100 
00102     real depth() const;
00103 
00105     void points(std::vector<Vector> &p) const;
00106 
00107     //
00108     // Set operations
00109     //
00110 
00112     void reset();
00113 
00115     BoundingBox &operator+=(const Vector &p);
00117     BoundingBox &operator+=(const std::vector<Vector> &p);
00119     BoundingBox &operator+=(const BoundingBox &box);
00121     BoundingBox &operator*=(const BoundingBox &box);
00122 
00124     bool operator==(const BoundingBox &box) const;
00125 
00126 //  /// Closest distance to box
00127 //  Real   dist(const Vector &pos) const;
00128 
00130     bool inside(const Vector &pos) const;
00131 
00133     bool intersects(const BoundingBox &box) const;
00134 
00136     bool project(const Matrix &model,const Matrix &proj,const GltViewport &view);
00137 
00138 //  /// Intersect ray
00139 //  Real   intersect        (const Vector &p0,const Vector &p1) const;
00140 //  /// Intersect ray
00141 //  Vector intersectPosition(const Vector &p0,const Vector &p1) const;
00142 
00143 protected:
00144 
00146     bool   _defined;
00148     Vector _min;
00150     Vector _max;
00151 };
00152 
00153 #endif

Generated on Tue Nov 5 11:11:04 2002 for GLT by doxygen1.2.18