00001 /* 00002 svas_server -- virtual World Server of Svas 00003 Copyright (c) 2001, 2002 David Moreno Montero 00004 00005 00006 This program is free software; you can redistribute it and/or modify 00007 it under the terms of the GNU General Public License as published by 00008 the Free Software Foundation; either version 2 of the License, or 00009 (at your option) any later version. 00010 00011 This program is distributed in the hope that it will be useful, but 00012 WITHOUT ANY WARRANTY; without even the implied warranty of 00013 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00014 General Public License for more details. 00015 00016 You should have received a copy of the GNU General Public License 00017 along with this program; if not, write to the Free Software 00018 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 00019 02111-1307, USA. 00020 00021 */ 00022 00023 #ifndef __BOUNDING_BOX_H__ 00024 #define __BOUNDING_BOX_H__ 00025 00026 #include <string.h> 00027 #include "vector3d.h" 00028 00029 #define INF 1e99 00030 00031 class BoundingBox{ 00032 protected: 00033 /// The min and max of the bounding box 00034 Vector3d min, max; 00035 public: 00036 /// Creates a bounding box with the specified min and max vectors 00037 BoundingBox(Vector3d _min=Vector3d(-INF,-INF,-INF), 00038 Vector3d _max=Vector3d(INF,INF,INF)); 00039 00040 /// Converts the bounding box to a printable string 00041 string toString(void); 00042 00043 /// Sets the current bounding box to the passed one 00044 BoundingBox operator=(BoundingBox &); 00045 00046 00047 /// Checks if the bounding box contains a vector (or a point) 00048 inline bool contains(const Vector3d &v){ 00049 return ((v.x>min.x)&&(v.x<max.x)&& 00050 (v.y>min.y)&&(v.x<max.y)&& 00051 (v.z>min.z)&&(v.x<max.z)); 00052 }; 00053 }; 00054 00055 #endif