Main Page   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members   File Members  

panda/src/mathutil/boundingSphere.h

Go to the documentation of this file.
00001 // Filename: boundingSphere.h
00002 // Created by:  drose (01Oct99)
00003 //
00004 ////////////////////////////////////////////////////////////////////
00005 //
00006 // PANDA 3D SOFTWARE
00007 // Copyright (c) 2001, Disney Enterprises, Inc.  All rights reserved
00008 //
00009 // All use of this software is subject to the terms of the Panda 3d
00010 // Software license.  You should have received a copy of this license
00011 // along with this source code; you will also find a current copy of
00012 // the license at http://www.panda3d.org/license.txt .
00013 //
00014 // To contact the maintainers of this program write to
00015 // panda3d@yahoogroups.com .
00016 //
00017 ////////////////////////////////////////////////////////////////////
00018 
00019 #ifndef BOUNDINGSPHERE_H
00020 #define BOUNDINGSPHERE_H
00021 
00022 #include <pandabase.h>
00023 
00024 #include "finiteBoundingVolume.h"
00025 
00026 ///////////////////////////////////////////////////////////////////
00027 //       Class : BoundingSphere
00028 // Description : This defines a bounding sphere, consisting of a
00029 //               center and a radius.  It is always a sphere, and
00030 //               never an ellipsoid or other quadric.
00031 ////////////////////////////////////////////////////////////////////
00032 class EXPCL_PANDA BoundingSphere : public FiniteBoundingVolume {
00033 PUBLISHED:
00034   INLINE_MATHUTIL BoundingSphere();
00035   INLINE_MATHUTIL BoundingSphere(const LPoint3f &center, float radius);
00036 
00037 public:
00038   virtual BoundingVolume *make_copy() const;
00039 
00040   virtual LPoint3f get_min() const;
00041   virtual LPoint3f get_max() const;
00042 
00043   virtual LPoint3f get_approx_center() const;
00044   virtual void xform(const LMatrix4f &mat);
00045 
00046   virtual void output(ostream &out) const;
00047 
00048 PUBLISHED:
00049   INLINE_MATHUTIL const LPoint3f &get_center() const;
00050   INLINE_MATHUTIL float get_radius() const;
00051 
00052 protected:
00053   virtual bool extend_other(BoundingVolume *other) const;
00054   virtual bool around_other(BoundingVolume *other,
00055                             const BoundingVolume **first,
00056                             const BoundingVolume **last) const;
00057   virtual int contains_other(const BoundingVolume *other) const;
00058 
00059 
00060   virtual bool extend_by_point(const LPoint3f &point);
00061   virtual bool extend_by_sphere(const BoundingSphere *sphere);
00062   virtual bool extend_by_hexahedron(const BoundingHexahedron *hexahedron);
00063   bool extend_by_finite(const FiniteBoundingVolume *volume);
00064 
00065   virtual bool around_points(const LPoint3f *first,
00066                              const LPoint3f *last);
00067   virtual bool around_spheres(const BoundingVolume **first,
00068                               const BoundingVolume **last);
00069   virtual bool around_hexahedrons(const BoundingVolume **first,
00070                                   const BoundingVolume **last);
00071   bool around_finite(const BoundingVolume **first,
00072                      const BoundingVolume **last);
00073 
00074   virtual int contains_point(const LPoint3f &point) const;
00075   virtual int contains_lineseg(const LPoint3f &a, const LPoint3f &b) const;
00076   virtual int contains_hexahedron(const BoundingHexahedron *hexahedron) const;
00077   virtual int contains_sphere(const BoundingSphere *sphere) const;
00078   virtual int contains_line(const BoundingLine *line) const;
00079 
00080 private:
00081   LPoint3f _center;
00082   float _radius;
00083 
00084 
00085 public:
00086   static TypeHandle get_class_type() {
00087     return _type_handle;
00088   }
00089   static void init_type() {
00090     FiniteBoundingVolume::init_type();
00091     register_type(_type_handle, "BoundingSphere",
00092                   FiniteBoundingVolume::get_class_type());
00093   }
00094   virtual TypeHandle get_type() const {
00095     return get_class_type();
00096   }
00097   virtual TypeHandle force_init_type() {init_type(); return get_class_type();}
00098 
00099 private:
00100   static TypeHandle _type_handle;
00101 
00102   friend class BoundingHexahedron;
00103 };
00104 
00105 #include "boundingSphere.I"
00106 
00107 #endif

Generated on Fri May 2 00:40:24 2003 for Panda by doxygen1.3