Panda3D
 All Classes Functions Variables Enumerations
boundingLine.h
00001 // Filename: boundingLine.h
00002 // Created by:  drose (04Jul00)
00003 //
00004 ////////////////////////////////////////////////////////////////////
00005 //
00006 // PANDA 3D SOFTWARE
00007 // Copyright (c) Carnegie Mellon University.  All rights reserved.
00008 //
00009 // All use of this software is subject to the terms of the revised BSD
00010 // license.  You should have received a copy of this license along
00011 // with this source code in a file named "LICENSE."
00012 //
00013 ////////////////////////////////////////////////////////////////////
00014 
00015 #ifndef BOUNDINGLINE_H
00016 #define BOUNDINGLINE_H
00017 
00018 #include "pandabase.h"
00019 
00020 #include "geometricBoundingVolume.h"
00021 
00022 ////////////////////////////////////////////////////////////////////
00023 //       Class : BoundingLine
00024 // Description : This funny bounding volume is an infinite line with
00025 //               no thickness and extending to infinity in both
00026 //               directions.
00027 //
00028 //               Note that it *always* extends in both directions,
00029 //               despite the fact that you specify two points to the
00030 //               constructor.  These are not endpoints, they are two
00031 //               arbitrary points on the line.
00032 ////////////////////////////////////////////////////////////////////
00033 class EXPCL_PANDA_MATHUTIL BoundingLine : public GeometricBoundingVolume {
00034 public:
00035   INLINE_MATHUTIL BoundingLine();
00036 
00037 PUBLISHED:
00038   INLINE_MATHUTIL BoundingLine(const LPoint3 &a, const LPoint3 &b);
00039   ALLOC_DELETED_CHAIN(BoundingLine);
00040 
00041 public:
00042   virtual BoundingVolume *make_copy() const;
00043 
00044   virtual LPoint3 get_approx_center() const;
00045   virtual void xform(const LMatrix4 &mat);
00046 
00047   virtual void output(ostream &out) const;
00048 
00049 PUBLISHED:
00050   INLINE_MATHUTIL const LPoint3 &get_point_a() const;
00051   INLINE_MATHUTIL LPoint3 get_point_b() const;
00052 
00053 public:
00054   virtual const BoundingLine *as_bounding_line() const;
00055 
00056 protected:
00057   virtual bool extend_other(BoundingVolume *other) const;
00058   virtual bool around_other(BoundingVolume *other,
00059                             const BoundingVolume **first,
00060                             const BoundingVolume **last) const;
00061   virtual int contains_other(const BoundingVolume *other) const;
00062 
00063   virtual bool extend_by_line(const BoundingLine *line);
00064 
00065   virtual int contains_sphere(const BoundingSphere *sphere) const;
00066   virtual int contains_box(const BoundingBox *box) const;
00067 
00068   PN_stdfloat sqr_dist_to_line(const LPoint3 &point) const;
00069 
00070 private:
00071   LPoint3 _origin;
00072   LVector3 _vector;
00073 
00074 
00075 public:
00076   static TypeHandle get_class_type() {
00077     return _type_handle;
00078   }
00079   static void init_type() {
00080     GeometricBoundingVolume::init_type();
00081     register_type(_type_handle, "BoundingLine",
00082                   GeometricBoundingVolume::get_class_type());
00083   }
00084   virtual TypeHandle get_type() const {
00085     return get_class_type();
00086   }
00087   virtual TypeHandle force_init_type() {init_type(); return get_class_type();}
00088 
00089 private:
00090   static TypeHandle _type_handle;
00091 
00092   friend class BoundingSphere;
00093   friend class BoundingBox;
00094 };
00095 
00096 #include "boundingLine.I"
00097 
00098 #endif
 All Classes Functions Variables Enumerations