41 #include <visp3/core/vpConfig.h>
42 #include <visp3/core/vpException.h>
43 #include <visp3/core/vpImagePoint.h>
82 vpRect(
double left,
double top,
double width,
double height);
86 VP_EXPLICIT
vpRect(
const std::vector<vpImagePoint> &ip);
91 inline double getArea()
const {
return width * height; }
97 inline double getBottom()
const {
return ((this->top + this->height) - 1.0); }
107 bottomLeft.
set_u(getLeft());
108 bottomLeft.
set_v(getBottom());
120 bottomRight.
set_u(getRight());
121 bottomRight.
set_v(getBottom());
138 x = (this->left + (this->width / 2.0)) - 0.5;
139 y = (this->top + (this->height / 2.0)) - 0.5;
155 center.
set_u((this->left + (this->width / 2.0)) - 0.5);
156 center.
set_v((this->top + (this->height / 2.0)) - 0.5);
166 inline double getHeight()
const {
return this->height; }
173 inline double getLeft()
const {
return this->left; }
179 inline double getRight()
const {
return ((this->left + this->width) - 1.0); }
185 inline double getSize()
const {
return (this->width * this->height); }
192 inline double getTop()
const {
return this->top; }
202 topLeft.
set_u(getLeft());
203 topLeft.
set_v(getTop());
215 topRight.
set_u(getRight());
216 topRight.
set_v(getTop());
227 inline double getWidth()
const {
return this->width; }
234 bool operator==(
const vpRect &r)
const;
235 bool operator!=(
const vpRect &r)
const;
245 double x1 = std::max<double>(left, r.left);
246 double y1 = std::max<double>(top, r.top);
247 width = std::min<double>(left + width, r.left + r.width) - x1;
248 height = std::min<double>(top + height, r.top + r.height) - y1;
252 if ((width <= 0) || (height <= 0)) {
273 friend VISP_EXPORT std::ostream &operator<<(std::ostream &os,
const vpRect &r);
275 void set(
double left,
double top,
double width,
double height);
276 void set(
const vpImagePoint &topLeft,
double width,
double height);
278 void set(
const vpRect &r);
279 void set(
const std::vector<vpImagePoint> &ip);
288 inline void setBottom(
double pos) { this->height = (pos - this->top) + 1.0; }
298 this->height = (bottomRight.
get_v() - this->top) + 1.0;
299 this->width = (bottomRight.
get_u() - this->left) + 1.0;
321 inline void setLeft(
double pos) { this->left = pos; }
333 inline void setRect(
double l,
double t,
double w,
double h)
348 inline void setRight(
double pos) { this->width = (pos - this->left) + 1.0; }
357 inline void setTop(
double pos) { this->top = pos; }
368 this->left = topLeft.
get_u();
369 this->top = topLeft.
get_v();
392 const unsigned int magic_2 = 2;
393 this->left = (x - (this->width / magic_2)) + 0.5;
394 this->top = (y - (this->height / magic_2)) + 0.5;
405 const unsigned int magic_2 = 2;
406 this->left = (center.
get_u() - (this->width / magic_2)) + 0.5;
407 this->top = (center.
get_v() - (this->height / magic_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