BoundBox.h

Go to the documentation of this file.
00001 // ----------------------------------------------------------------------------
00002 //
00003 // $Id$
00004 //
00005 // Copyright 2008, 2009, 2010, 2011, 2012  Antonio Franchi and Paolo Stegagno    
00006 //
00007 // This file is part of MIP.
00008 //
00009 // MIP is free software: you can redistribute it and/or modify
00010 // it under the terms of the GNU General Public License as published by
00011 // the Free Software Foundation, either version 3 of the License, or
00012 // (at your option) any later version.
00013 //
00014 // MIP is distributed in the hope that it will be useful,
00015 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00016 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00017 // GNU General Public License for more details.
00018 //
00019 // You should have received a copy of the GNU General Public License
00020 // along with MIP. If not, see <http://www.gnu.org/licenses/>.
00021 //
00022 // Contact info: antonio.franchi@tuebingen.mpg.de stegagno@diag.uniroma1.it
00023 //
00024 // ----------------------------------------------------------------------------
00025 
00026 
00030 
00032 /* @{ */
00033 
00034 
00035 #ifndef __BOUND_BOX_H_
00036 #define __BOUND_BOX_H_
00037 
00038 #ifdef MIP_HOST_APPLE
00039 #include <applePatch.h>
00040 #endif
00041 
00042 #include <stdio.h>
00043 #include <math.h>
00044 #include <vector>
00045 #include <iostream>
00046 #include <string>
00047 #include <sstream>
00048 #include <sys/time.h>
00049 #include <sys/select.h>
00050 #include <assert.h>
00051 
00052 #ifdef FOUND_BOOST_SER
00053  #include <boost/serialization/vector.hpp>
00054  #include <boost/archive/text_iarchive.hpp>
00055  #include <boost/archive/text_oarchive.hpp>
00056 #endif
00057 
00058 #include <Types.h>
00059 
00060 #include <SE2.h>
00061 
00062 using namespace std;
00063 
00064 
00068 class BoundBox{
00069  protected:
00070   
00071   static const Decimal BB_DEFAULT_XMIN; 
00072   static const Decimal BB_DEFAULT_YMIN; 
00073   static const Decimal BB_DEFAULT_XMAX; 
00074   static const Decimal BB_DEFAULT_YMAX; 
00075   bool _clear;  
00076   bool _locked; 
00077   
00079   void unlock(){
00080    _locked = false;
00081   }
00083   void lock(){
00084    _locked = true;
00085   }
00086   
00087  public:
00088   Decimal xm; 
00089   Decimal ym; 
00090   Decimal xM; 
00091   Decimal yM; 
00092   
00094   BoundBox();
00095   
00101   BoundBox(Decimal xm,Decimal ym,Decimal xM,Decimal yM);
00102   
00106   BoundBox(Position p1,Position p2);
00107   
00112   void extend(BoundBox bb);
00113   
00118   void extend(Position p);
00119   
00122   Decimal diameter(){
00123    return sqrt((xM-xm)*(xM-xm) + (yM-ym)*(yM-ym));
00124   }
00125   
00128   Decimal width(){
00129    return xM - xm;
00130   }
00131   
00134   Decimal height(){
00135    return yM - ym;
00136   }
00137   
00140   Position center(){
00141    return Position( (xM+xm)/2.0 , (yM+ym)/2.0 );
00142   }
00143   
00146   const BoundBox operator*(Pose p);
00147   
00150   void clear(){
00151    _clear = true;
00152    unlock();
00153   }
00154 };
00155 
00156 
00157 
00158 #endif
00159 
00160 
00161 
00162 /* @} */

Generated on Mon Feb 20 07:01:07 2017 for MIP by  doxygen 1.5.6