inlib  1.2.0
/Users/barrand/private/dev/softinex/old/inexlib-1.2/inlib/inlib/spheref
Go to the documentation of this file.
00001 // Copyright (C) 2010, Guy Barrand. All rights reserved.
00002 // See the file inlib.license for terms.
00003 
00004 #ifndef inlib_spheref
00005 #define inlib_spheref
00006 
00007 #include "vec3f"
00008 #include "box3f"
00009 #include "fmath"
00010 
00011 namespace inlib {
00012 
00013 class spheref {
00014 public:
00015   spheref(const vec3f& a_center,float a_radius)
00016   :m_center(a_center),m_radius(a_radius)
00017   {}
00018   virtual ~spheref(){}  
00019 public:
00020   spheref(const spheref& a_from)
00021   :m_center(a_from.m_center)
00022   ,m_radius(a_from.m_radius)
00023   {}
00024   spheref& operator=(const spheref& a_from){
00025     m_center = a_from.m_center;
00026     m_radius = a_from.m_radius;
00027     return *this;
00028   }
00029 public:
00030   const vec3f& center() const {return m_center;}
00031   float radius() const {return m_radius;}
00032   bool circumscribe(const box3f& a_box){
00033     if(!a_box.center(m_center)) return false;
00034     float dx,dy,dz;
00035     if(!a_box.get_size(dx,dy,dz)) return false;
00036     m_radius = fsqrt(dx*dx + dy*dy + dz*dz)/2.0f;
00037     return true;
00038   }
00039 private:
00040   vec3f m_center;
00041   float m_radius;
00042 };
00043 
00044 }
00045 
00046 #endif
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines