OpenPose  1.0.0rc2
OpenPose: A Real-Time Multi-Person Key-Point Detection And Multi-Threading C++ Library
 All Classes Namespaces Files Functions Variables Enumerations Enumerator Macros
rectangle.hpp
Go to the documentation of this file.
1 #ifndef OPENPOSE_CORE_RECTANGLE_HPP
2 #define OPENPOSE_CORE_RECTANGLE_HPP
3 
4 #include <string>
6 
7 namespace op
8 {
9  template<typename T>
10  struct Rectangle
11  {
12  T x;
13  T y;
14  T width;
15  T height;
16 
17  Rectangle(const T x = 0, const T y = 0, const T width = 0, const T height = 0);
18 
26  Rectangle<T>(const Rectangle<T>& rectangle);
27 
34  Rectangle<T>& operator=(const Rectangle<T>& rectangle);
35 
41  Rectangle<T>(Rectangle<T>&& rectangle);
42 
49  Rectangle<T>& operator=(Rectangle<T>&& rectangle);
50 
51  Point<T> center() const;
52 
53  inline Point<T> topLeft() const
54  {
55  return Point<T>{x, y};
56  }
57 
58  Point<T> bottomRight() const;
59 
60  inline T area() const
61  {
62  return width * height;
63  }
64 
65  void recenter(const T newWidth, const T newHeight);
66 
72  std::string toString() const;
73 
74  // -------------------------------------------------- Basic Operators -------------------------------------------------- //
75  Rectangle<T>& operator*=(const T value);
76 
77  Rectangle<T> operator*(const T value) const;
78 
79  Rectangle<T>& operator/=(const T value);
80 
81  Rectangle<T> operator/(const T value) const;
82  };
83 
84  // Static methods
85  template<typename T>
86  Rectangle<T> recenter(const Rectangle<T>& rectangle, const T newWidth, const T newHeight);
87 }
88 
89 #endif // OPENPOSE_CORE_RECTANGLE_HPP
Point< T > center() const
Rectangle< T > & operator=(const Rectangle< T > &rectangle)
Rectangle(const T x=0, const T y=0, const T width=0, const T height=0)
T y
Definition: rectangle.hpp:13
void recenter(const T newWidth, const T newHeight)
Definition: point.hpp:9
Rectangle< T > operator/(const T value) const
Rectangle< T > & operator/=(const T value)
std::string toString() const
Point< T > bottomRight() const
Rectangle< T > operator*(const T value) const
T height
Definition: rectangle.hpp:15
Point< T > topLeft() const
Definition: rectangle.hpp:53
T width
Definition: rectangle.hpp:14
T x
Definition: rectangle.hpp:12
Rectangle< T > & operator*=(const T value)
Definition: rectangle.hpp:10
Rectangle< T > recenter(const Rectangle< T > &rectangle, const T newWidth, const T newHeight)
T area() const
Definition: rectangle.hpp:60