72 #include <visp3/core/vpException.h>
73 #include <visp3/core/vpImagePoint.h>
79 vpRect(
double left,
double top,
double width,
double height);
83 explicit vpRect(
const std::vector<vpImagePoint> &ip);
88 inline double getArea()
const {
return width * height; }
94 inline double getBottom()
const {
return (this->top + this->height - 1.0); }
104 bottomLeft.
set_u(getLeft());
105 bottomLeft.
set_v(getBottom());
117 bottomRight.
set_u(getRight());
118 bottomRight.
set_v(getBottom());
135 x = this->left + this->width / 2.0 - 0.5;
136 y = this->top + this->height / 2.0 - 0.5;
152 center.
set_u(this->left + this->width / 2.0 - 0.5);
153 center.
set_v(this->top + this->height / 2.0 - 0.5);
163 inline double getHeight()
const {
return this->height; }
170 inline double getLeft()
const {
return this->left; }
176 inline double getRight()
const {
return (this->left + this->width - 1.0); }
182 inline double getSize()
const {
return (this->width * this->height); }
189 inline double getTop()
const {
return this->top; }
199 topLeft.
set_u(getLeft());
200 topLeft.
set_v(getTop());
212 topRight.
set_u(getRight());
213 topRight.
set_v(getTop());
224 inline double getWidth()
const {
return this->width; }
231 bool operator==(
const vpRect &r)
const;
232 bool operator!=(
const vpRect &r)
const;
242 double x1 = (std::max)(left, r.left);
243 double y1 = (std::max)(top, r.top);
244 width = (std::min)(left + width, r.left + r.width) - x1;
245 height = (std::min)(top + height, r.top + r.height) - y1;
249 if (width <= 0 || height <= 0) {
270 friend VISP_EXPORT std::ostream &operator<<(std::ostream &os,
const vpRect &r);
272 void set(
double left,
double top,
double width,
double height);
273 void set(
const vpImagePoint &topLeft,
double width,
double height);
275 void set(
const vpRect &r);
276 void set(
const std::vector<vpImagePoint> &ip);
285 inline void setBottom(
double pos) { this->height = pos - this->top + 1.0; }
295 this->height = bottomRight.
get_v() - this->top + 1.0;
296 this->width = bottomRight.
get_u() - this->left + 1.0;
318 inline void setLeft(
double pos) { this->left = pos; }
330 inline void setRect(
double l,
double t,
double w,
double h)
345 inline void setRight(
double pos) { this->width = pos - this->left + 1.0; }
354 inline void setTop(
double pos) { this->top = pos; }
365 this->left = topLeft.
get_u();
366 this->top = topLeft.
get_v();
389 this->left = x - this->width / 2 + 0.5;
390 this->top = y - this->height / 2 + 0.5;
401 this->left = center.
get_u() - this->width / 2 + 0.5;
402 this->top = center.
get_v() - this->height / 2 + 0.5;
Class that defines a 2D point in an image. This class is useful for image processing and stores only ...
Defines a rectangle in the plane.
void getCenter(double &x, double &y) const
vpRect & operator&=(const vpRect &r)
void moveCenter(const vpImagePoint ¢er)
void moveCenter(double x, double y)
vpImagePoint getBottomLeft() const
void setBottomRight(const vpImagePoint &bottomRight)
void setTopLeft(const vpImagePoint &topLeft)
vpImagePoint getTopLeft() const
vpImagePoint getTopRight() const
vpRect operator&(const vpRect &r) const
void setRect(double l, double t, double w, double h)
vpImagePoint getCenter() const
void setRight(double pos)
void setBottom(double pos)
vpImagePoint getBottomRight() const