FXSphered.h

Go to the documentation of this file.
00001 /********************************************************************************
00002 *                                                                               *
00003 *           D o u b l e - P r e c i s i o n    S p h e r e    C l a s s         *
00004 *                                                                               *
00005 *********************************************************************************
00006 * Copyright (C) 2004,2006 by Jeroen van der Zijp.   All Rights Reserved.        *
00007 *********************************************************************************
00008 * This library is free software; you can redistribute it and/or                 *
00009 * modify it under the terms of the GNU Lesser General Public                    *
00010 * License as published by the Free Software Foundation; either                  *
00011 * version 2.1 of the License, or (at your option) any later version.            *
00012 *                                                                               *
00013 * This library is distributed in the hope that it will be useful,               *
00014 * but WITHOUT ANY WARRANTY; without even the implied warranty of                *
00015 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU             *
00016 * Lesser General Public License for more details.                               *
00017 *                                                                               *
00018 * You should have received a copy of the GNU Lesser General Public              *
00019 * License along with this library; if not, write to the Free Software           *
00020 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA.    *
00021 *********************************************************************************
00022 * $Id: FXSphered.h,v 1.17 2006/01/22 17:58:09 fox Exp $                         *
00023 ********************************************************************************/
00024 #ifndef FXSPHERED_H
00025 #define FXSPHERED_H
00026 
00027 
00028 namespace FX {
00029 
00030 
00031 class FXRanged;
00032 
00033 
00035 class FXAPI FXSphered {
00036 public:
00037   FXVec3d  center;
00038   FXdouble radius;
00039 public:
00040 
00042   FXSphered(){}
00043 
00045   FXSphered(const FXSphered& sphere):center(sphere.center),radius(sphere.radius){}
00046 
00048   FXSphered(const FXVec3d& cen,FXdouble rad=0.0):center(cen),radius(rad){}
00049 
00051   FXSphered(FXdouble x,FXdouble y,FXdouble z,FXdouble rad=0.0):center(x,y,z),radius(rad){}
00052 
00054   FXSphered(const FXRanged& bounds);
00055 
00057   FXSphered& operator=(const FXSphered& sphere){ center=sphere.center; radius=sphere.radius; return *this; }
00058 
00060   FXSphered& set(const FXSphered& sphere){ center=sphere.center; radius=sphere.radius; return *this; }
00061 
00063   FXSphered& set(const FXVec3d& cen,FXdouble rad){ center=cen; radius=rad; return *this; }
00064 
00066   FXSphered& set(FXdouble x,FXdouble y,FXdouble z,FXdouble rad){ center.set(x,y,z); radius=rad; return *this; }
00067 
00069   bool operator==(const FXSphered& s) const { return center==s.center && radius==s.radius;}
00070   bool operator!=(const FXSphered& s) const { return center!=s.center || radius!=s.radius;}
00071 
00073   FXdouble diameter() const { return radius*2.0; }
00074 
00076   bool empty() const { return radius<0.0; }
00077 
00079   bool contains(FXdouble x,FXdouble y,FXdouble z) const;
00080 
00082   bool contains(const FXVec3d& p) const;
00083 
00085   bool contains(const FXRanged& box) const;
00086 
00088   bool contains(const FXSphered& sphere) const;
00089 
00091   FXSphered& include(FXdouble x,FXdouble y,FXdouble z);
00092 
00094   FXSphered& include(const FXVec3d& p);
00095 
00097   FXSphered& includeInRadius(FXdouble x,FXdouble y,FXdouble z);
00098 
00100   FXSphered& includeInRadius(const FXVec3d& p);
00101 
00103   FXSphered& include(const FXRanged& box);
00104 
00106   FXSphered& includeInRadius(const FXRanged& box);
00107 
00109   FXSphered& include(const FXSphered& sphere);
00110 
00112   FXSphered& includeInRadius(const FXSphered& sphere);
00113 
00115   FXint intersect(const FXVec4d& plane) const;
00116 
00118   bool intersect(const FXVec3d& u,const FXVec3d& v) const;
00119 
00121   friend FXAPI bool overlap(const FXRanged& a,const FXSphered& b);
00122 
00124   friend FXAPI bool overlap(const FXSphered& a,const FXRanged& b);
00125 
00127   friend FXAPI bool overlap(const FXSphered& a,const FXSphered& b);
00128 
00130   friend FXAPI FXStream& operator<<(FXStream& store,const FXSphered& sphere);
00131 
00133   friend FXAPI FXStream& operator>>(FXStream& store,FXSphered& sphere);
00134   };
00135 
00136 
00137 extern FXAPI bool overlap(const FXRanged& a,const FXSphered& b);
00138 extern FXAPI bool overlap(const FXSphered& a,const FXRanged& b);
00139 extern FXAPI bool overlap(const FXSphered& a,const FXSphered& b);
00140 
00141 extern FXAPI FXStream& operator<<(FXStream& store,const FXSphered& sphere);
00142 extern FXAPI FXStream& operator>>(FXStream& store,FXSphered& sphere);
00143 
00144 }
00145 
00146 #endif

(C) 2002-2009 Niall Douglas. Some parts (C) to assorted authors.
Generated on Fri Nov 20 18:31:24 2009 for TnFOX by doxygen v1.4.7