00001
00002
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00031
00032 #ifndef RCSC_GEOM_SIZE2D_H
00033 #define RCSC_GEOM_SIZE2D_H
00034
00035 #include <ostream>
00036 #include <cmath>
00037
00038 namespace rcsc {
00039
00044 class Size2D {
00045 private:
00047 double M_length;
00048
00050 double M_width;
00051
00052 public:
00053
00057 Size2D()
00058 : M_length( 0.0 )
00059 , M_width( 0.0 )
00060 { }
00061
00067 Size2D( const double & length,
00068 const double & width )
00069 : M_length( std::fabs( length ) )
00070 , M_width( std::fabs( width ) )
00071 { }
00072
00079 const
00080 Size2D & assign( const double & length,
00081 const double & width )
00082 {
00083 M_length = std::fabs( length );
00084 M_width = std::fabs( width );
00085 return *this;
00086 }
00087
00093 const
00094 Size2D & setLength( const double & length )
00095 {
00096 M_length = std::fabs( length );
00097 return *this;
00098 }
00099
00105 const
00106 Size2D & setWidth( const double & width )
00107 {
00108 M_width = std::fabs( width );
00109 return *this;
00110 }
00111
00116 const
00117 double & length() const
00118 {
00119 return M_length;
00120 }
00121
00126 const
00127 double & width() const
00128 {
00129 return M_width;
00130 }
00131
00136 double diagonal() const
00137 {
00138 return std::sqrt( length() * length()
00139 + width() * width() );
00140 }
00141
00147 std::ostream & print( std::ostream & os ) const
00148 {
00149 os << "(" << length() << ", " << width() << ")";
00150 return os;
00151 }
00152
00153 };
00154
00155 }
00156
00157 #endif