shape_doc 0.1
/Users/mourrain/Devel/mmx/shape/include/shape/plane.hpp
Go to the documentation of this file.
00001 /*****************************************************************************
00002  * M a t h e m a g i x
00003  *****************************************************************************
00004  * Plane
00005  * 2008-06-24
00006  * Julien Wintz
00007  *****************************************************************************
00008  *               Copyright (C) 2006 INRIA Sophia-Antipolis
00009  *****************************************************************************
00010  * Comments :
00011  ****************************************************************************/
00012 
00013 # ifndef shape_plane_hpp
00014 # define shape_plane_hpp
00015 
00016 //# include <realroot/polynomial_monomialtensor.hpp>
00017 #include <realroot/polynomial_tensor.hpp>
00018 
00019 # include <shape/shape.hpp>
00020 # define TMPL template<class K>
00021 # define Shape geometric<K>
00022 # define Plane plane<K>
00023 # define POLYNOMIAL polynomial< double,with<MonomialTensor> >
00024 
00025 namespace mmx {
00026 
00027 namespace shape {
00028 TMPL
00029 class plane : public Shape
00030 {
00031 public:
00032   plane(void) ;
00033   plane(const char * equation) ;
00034   plane(const Plane & other) ;
00035   
00036   inline double a(void) const ;
00037   inline double b(void) const ;
00038   inline double c(void) const ;
00039   inline double d(void) const ;
00040   
00041   POLYNOMIAL equation(void) const ;
00042   
00043   bool     operator == (const Plane & other) const ;
00044   bool     operator != (const Plane & other) const ;
00045   Plane  & operator  = (const Plane & other) ;
00046   double & operator [] (const int & i) ;
00047 
00048 private:
00049   POLYNOMIAL m_polynomial ;
00050 };
00051 
00052 TMPL Plane::plane(void)
00053 {
00054     this->m_polynomial =POLYNOMIAL("x") ;
00055 }
00056 
00057 TMPL Plane::plane(const char * equation)
00058 {
00059     this->m_polynomial =POLYNOMIAL(equation) ;
00060 }
00061 
00062 TMPL Plane::plane(const Plane & other) {
00063   m_polynomial = other.m_polynomial ;
00064 }
00065 
00066 TMPL double 
00067 Plane::a(void) const {
00068   return m_polynomial[1] ;
00069 }
00070 
00071 TMPL double 
00072 Plane::b(void) const {
00073     return m_polynomial[2] ;
00074 }
00075 
00076 TMPL double 
00077 Plane::c(void) const {
00078   return m_polynomial[3] ;
00079 }
00080 
00081 TMPL double 
00082 Plane::d(void) const {
00083   return m_polynomial[0] ;
00084 }
00085 
00086 TMPL POLYNOMIAL 
00087 Plane::equation(void) const {
00088   return m_polynomial ;
00089 }
00090 
00094 TMPL bool 
00095 Plane::operator == (const Plane & other) const {
00096   return (this->m_polynomial == other.m_polynomial) ;
00097 }
00098 
00102 TMPL bool 
00103 Plane::operator != (const Plane & other) const {
00104   return !(m_polynomial == other.m_polynomial) ;
00105 }
00106 
00107 TMPL Plane& 
00108 Plane::operator = (const Plane & other) {
00109   if(this == &other)
00110     return *this ;
00111     
00112   this->m_polynomial = other.equation() ;
00113   
00114   return * this ;
00115 }
00116 
00117 TMPL double & 
00118 Plane::operator [] (const int & i) {
00119   switch(i) {
00120   case 0:
00121     return m_polynomial[1] ; 
00122     break ;
00123   case 1:
00124     return m_polynomial[2] ;
00125         break ;
00126   case 2:
00127     return m_polynomial[3] ;
00128     break ;
00129   case 3:
00130     return m_polynomial[0] ;
00131     break ;
00132   default:
00133     break ;
00134   }
00135   
00136   return *(new double(0.0)) ;
00137 }
00138 
00139 
00140 } ; // namespace shape
00141 } ; // namespace mmx
00142 # undef TMPL
00143 # undef Plane
00144 # undef POLYNOMIAL
00145 # undef Shape
00146 # endif // shape_plane_hpp