00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00031 #ifndef __CLAW_RECTANGLE_HPP__
00032 #define __CLAW_RECTANGLE_HPP__
00033
00034 #include <claw/coordinate_2d.hpp>
00035
00036 namespace claw
00037 {
00038 namespace math
00039 {
00045 template<class T>
00046 class rectangle
00047 {
00048 public:
00050 typedef T value_type;
00051
00053 typedef rectangle<value_type> self_type;
00054
00055 public:
00056 rectangle();
00057
00058 template<typename U>
00059 rectangle( const rectangle<U>& that );
00060
00061 rectangle( const value_type& _x, const value_type& _y,
00062 const value_type& _width, const value_type& _height);
00063
00064 template<typename U>
00065 rectangle( const coordinate_2d<U>& pos, const value_type& _width,
00066 const value_type& _height );
00067
00068 template<typename U>
00069 rectangle( const coordinate_2d<U>& pos, const coordinate_2d<U>& size );
00070
00071 template<typename U>
00072 rectangle<U> cast_value_type_to() const;
00073
00074 value_type area() const;
00075 bool includes( const coordinate_2d<value_type>& p ) const;
00076 bool includes( const self_type& r ) const;
00077 bool intersects( const self_type& r ) const;
00078 self_type intersection( const self_type& r ) const;
00079
00080 void set( const value_type& new_x, const value_type& new_y,
00081 const value_type& new_width, const value_type& new_height );
00082
00083 value_type right() const;
00084 value_type bottom() const;
00085
00086 coordinate_2d<value_type> size() const;
00087
00088 private:
00089 void x_intersection( const self_type& r, self_type& result ) const;
00090 void y_intersection( const self_type& r, self_type& result ) const;
00091
00092 public:
00094 coordinate_2d<value_type> position;
00095
00097 value_type width;
00098
00100 value_type height;
00101
00102 };
00103 }
00104 }
00105
00106 #include <claw/impl/rectangle.tpp>
00107
00108 #endif // __CLAW_RECTANGLE_HPP__