right_rectangle.cpp
1 #include "right_rectangle.hpp"
2 
4  const Vector2D& upper_right):
5  lower_left_(lower_left), upper_right_(upper_right)
6 {
7  assert(upper_right.x>lower_left.x &&
8  upper_right.y>lower_left.y &&
9  "vertices are reversed");
10 }
11 
12 RightRectangle::RightRectangle(const pair<Vector2D,Vector2D>& ll_ur):
13  lower_left_(ll_ur.first), upper_right_(ll_ur.second)
14 {
15  assert(upper_right_.x>lower_left_.x &&
16  upper_right_.y>lower_left_.y &&
17  "vertices are reversed");
18 }
19 
20 namespace
21 {
22  bool is_between(double x_cand,
23  double x_low,
24  double x_high)
25  {
26  return (x_high>x_cand)&&(x_cand>x_low);
27  }
28 }
29 
30 bool RightRectangle::operator()(const Vector2D& point) const
31 {
32  return is_between(point.x,lower_left_.x,upper_right_.x)&&
33  is_between(point.y,lower_left_.y,upper_right_.y);
34 }
RightRectangle(const Vector2D &lower_left, const Vector2D &upper_right)
Class constructor.
double y
Component in the y direction.
Definition: geometry.hpp:48
Defines a rectangular shape.
2D Mathematical vector
Definition: geometry.hpp:15
bool operator()(const Vector2D &point) const
Returns true is a point is inside the shape, false otherwise.
double x
Component in the x direction.
Definition: geometry.hpp:45