#include <box_2d.hpp>
Definition at line 46 of file box_2d.hpp.
Public Types | |
typedef T | value_type |
The type of the values we store. | |
typedef coordinate_2d< value_type > | point_type |
The type of the coordinates of the points representing the corners. | |
typedef box_2d< value_type > | self_type |
The type of the current class. | |
Public Member Functions | |
box_2d () | |
Constructor. | |
box_2d (const self_type &that) | |
Copy constructor. | |
box_2d (const rectangle< value_type > &that) | |
Constructor from a rectangle. | |
box_2d (const point_type &p1, const point_type &p2) | |
Constructor from two points. | |
box_2d (const value_type &x1, const value_type &y1, const value_type &x2, const value_type &y2) | |
Constructor with initialization. | |
value_type | width () const |
Return box' width. | |
value_type | height () const |
Return box' height. | |
bool | operator== (const self_type &vect) const |
Equality operator. | |
bool | operator!= (const self_type &vect) const |
Difference operator. | |
self_type | operator+ (const point_type &vect) const |
Translation. | |
self_type | operator- (const point_type &vect) const |
Translation. | |
self_type & | operator+= (const point_type &vect) |
Translation. | |
self_type & | operator-= (const point_type &vect) |
Translation. | |
Public Attributes | |
point_type | first_point |
The first of the two points, representing one corner. | |
point_type | second_point |
The second of the two points, representing an other corner. |
typedef T claw::math::box_2d< T >::value_type |
typedef coordinate_2d<value_type> claw::math::box_2d< T >::point_type |
The type of the coordinates of the points representing the corners.
Definition at line 54 of file box_2d.hpp.
typedef box_2d<value_type> claw::math::box_2d< T >::self_type |
claw::math::box_2d< T >::box_2d | ( | ) | [inline] |
claw::math::box_2d< T >::box_2d | ( | const self_type & | that | ) | [inline] |
Copy constructor.
that | Box to copy from. |
Definition at line 48 of file box_2d.tpp.
00049 : first_point(that.first_point), second_point(that.second_point) 00050 { 00051 00052 } // box_2d::box_2d() [copy constructor]
claw::math::box_2d< T >::box_2d | ( | const rectangle< value_type > & | that | ) | [inline] |
Constructor from a rectangle.
that | Rectangle to copy from. |
Definition at line 60 of file box_2d.tpp.
00061 : first_point(that.position), 00062 second_point(that.right(), that.bottom()) 00063 { 00064 00065 } // box_2d::box_2d() [constructor from rectangle]
claw::math::box_2d< T >::box_2d | ( | const point_type & | p1, | |
const point_type & | p2 | |||
) | [inline] |
Constructor from two points.
Definition at line 74 of file box_2d.tpp.
00075 : first_point(p1), second_point(p2) 00076 { 00077 00078 } // box_2d::box_2d() [constructor from coordinates]
claw::math::box_2d< T >::box_2d | ( | const value_type & | x1, | |
const value_type & | y1, | |||
const value_type & | x2, | |||
const value_type & | y2 | |||
) | [inline] |
Constructor with initialization.
x1 | X-coordinate of the first point. | |
y1 | Y-coordinate of the first point. | |
x2 | X-coordinate of the second point. | |
y2 | Y-coordinate of the second point. |
Definition at line 89 of file box_2d.tpp.
00091 : first_point(x1, y1), second_point(x2, y2) 00092 { 00093 00094 } // box_2d::box_2d() [constructor with values]
claw::math::box_2d< T >::value_type claw::math::box_2d< T >::width | ( | ) | const [inline] |
Return box' width.
Definition at line 175 of file box_2d.tpp.
References claw::math::box_2d< T >::first_point, claw::math::box_2d< T >::second_point, and claw::math::coordinate_2d< T >::x.
00176 { 00177 if (first_point.x > second_point.x) 00178 return first_point.x - second_point.x + 1; 00179 else 00180 return second_point.x - first_point.x + 1; 00181 } // box_2d::width()
claw::math::box_2d< T >::value_type claw::math::box_2d< T >::height | ( | ) | const [inline] |
Return box' height.
Definition at line 189 of file box_2d.tpp.
References claw::math::box_2d< T >::first_point, claw::math::box_2d< T >::second_point, and claw::math::coordinate_2d< T >::y.
00190 { 00191 if (first_point.y > second_point.y) 00192 return first_point.y - second_point.y + 1; 00193 else 00194 return second_point.y - first_point.y + 1; 00195 } // box_2d::height()
bool claw::math::box_2d< T >::operator== | ( | const self_type & | that | ) | const [inline] |
Equality operator.
that | Box to compare to. |
Definition at line 102 of file box_2d.tpp.
References claw::math::box_2d< T >::first_point, and claw::math::box_2d< T >::second_point.
00103 { 00104 return (first_point == that.first_point) 00105 && (second_point == that.second_point); 00106 } // box_2d::operator==()
bool claw::math::box_2d< T >::operator!= | ( | const self_type & | that | ) | const [inline] |
claw::math::box_2d< T > claw::math::box_2d< T >::operator+ | ( | const point_type & | vect | ) | const [inline] |
Translation.
vect | The vector to add to points. |
Definition at line 126 of file box_2d.tpp.
References claw::math::box_2d< T >::first_point, and claw::math::box_2d< T >::second_point.
00127 { 00128 return self_type( first_point + vect, second_point + vect ); 00129 } // box_2d::operator+()
claw::math::box_2d< T > claw::math::box_2d< T >::operator- | ( | const point_type & | vect | ) | const [inline] |
Translation.
vect | The vector to substract to points. |
Definition at line 138 of file box_2d.tpp.
References claw::math::box_2d< T >::first_point, and claw::math::box_2d< T >::second_point.
00139 { 00140 return self_type( first_point - vect, second_point - vect ); 00141 } // box_2d::operator-()
claw::math::box_2d< T > & claw::math::box_2d< T >::operator+= | ( | const point_type & | vect | ) | [inline] |
Translation.
vect | The vector to add to points. |
Definition at line 150 of file box_2d.tpp.
References claw::math::box_2d< T >::first_point, and claw::math::box_2d< T >::second_point.
00151 { 00152 first_point += vect; 00153 second_point += vect; 00154 } // box_2d::operator+=()
claw::math::box_2d< T > & claw::math::box_2d< T >::operator-= | ( | const point_type & | vect | ) | [inline] |
Translation.
vect | The vector to substract to points. |
Definition at line 163 of file box_2d.tpp.
References claw::math::box_2d< T >::first_point, and claw::math::box_2d< T >::second_point.
00164 { 00165 first_point -= vect; 00166 second_point -= vect; 00167 } // box_2d::operator-=()
point_type claw::math::box_2d< T >::first_point |
The first of the two points, representing one corner.
Definition at line 79 of file box_2d.hpp.
Referenced by claw::math::box_2d< T >::height(), claw::math::rectangle< T >::includes(), claw::math::box_2d< T >::operator+(), claw::math::box_2d< T >::operator+=(), claw::math::box_2d< T >::operator-(), claw::math::box_2d< T >::operator-=(), claw::math::box_2d< T >::operator==(), and claw::math::box_2d< T >::width().
point_type claw::math::box_2d< T >::second_point |
The second of the two points, representing an other corner.
Definition at line 82 of file box_2d.hpp.
Referenced by claw::math::box_2d< T >::height(), claw::math::rectangle< T >::includes(), claw::math::box_2d< T >::operator+(), claw::math::box_2d< T >::operator+=(), claw::math::box_2d< T >::operator-(), claw::math::box_2d< T >::operator-=(), claw::math::box_2d< T >::operator==(), and claw::math::box_2d< T >::width().