50 : position(that.position), width(that.width), height(that.height)
63 : position(that.left(), that.top()), width(that.width()),
81 : position(_x, _y), width(_width), height(_height)
98 : position(pos), width(_width), height(_height)
113 : position(pos), width(size.
x), height(size.
y)
143 ( position.cast_value_type_to<U>(), (U)width, (U)height );
155 && (height == that.
height);
166 return !(*
this == that);
177 return width * height;
189 return (position.x <= p.
x) && (right() >= p.
x)
190 && (position.y <= p.
y) && (bottom() >= p.
y);
215 && (r.
right() >= position.x)
217 && (r.
bottom() >= position.y);
233 x_intersection(r, result);
234 y_intersection(r, result);
250 const T result_left = std::min( left(), r.
left() );
251 const T result_top = std::min( top(), r.
top() );
252 const T result_bottom = std::max( bottom(), r.
bottom() );
253 const T result_right = std::max( right(), r.
right() );
256 ( result_left, result_top, result_right - result_left,
257 result_bottom - result_top );
298 return position.x + width;
309 return position.y + height;
342 (
const self_type& r, self_type& result )
const
344 if (position.x <= r.position.x)
348 if (right() >= r.right())
349 result.width = r.width;
351 result.width = right() - r.position.x;
354 r.x_intersection(*
this, result);
366 (
const self_type& r, self_type& result )
const
368 if (position.y <= r.position.y)
372 if (bottom() >= r.bottom())
373 result.height = r.height;
375 result.height = bottom() - r.position.y;
378 r.y_intersection(*
this, result);
T value_type
The type of the values we store.
coordinate_2d< value_type > position
value_typeop left coordinates.
coordinate_2d< value_type > size() const
Get the size of the rectangle.
point_type first_point
The first of the two points, representing one corner.
bool operator!=(const self_type &that) const
Tell if this rectangle equals an other rectangle.
void set(const value_type &new_x, const value_type &new_y, const value_type &new_width, const value_type &new_height)
set new position and size to the rectangle.
value_type right() const
Get the x-coordinate of the right edge.
self_type join(const self_type &r) const
Get the smallest rectangle bounding both this rectangle and another one.
bool intersects(const self_type &r) const
Tell if there is an intersection of two rectangles.
Coordinates in a two dimensional space.
A class representing a rectangle by his x,y coordinates, width and height.
value_type left() const
Get the x-coordinate of the left edge.
value_type area() const
Calculate the rectangle's area.
value_type y
Y-coordinate.
self_type intersection(const self_type &r) const
Intersection of two rectangles.
value_type bottom() const
Get the y-coordinate of the bottom edge.
point_type second_point
The second of the two points, representing an other corner.
bool operator==(const self_type &that) const
Tell if this rectangle equals an other rectangle.
A rectangle represented by two points in a 2D space.
value_type top() const
Get the y-coordinate of the top edge.
bool includes(const coordinate_2d< value_type > &p) const
Tell if a point is in a rectangle.
value_type x
X-coordinate.