76 #include <visp3/core/vpException.h> 77 #include <visp3/core/vpImagePoint.h> 83 vpRect(
double left,
double top,
double width,
double height);
87 explicit vpRect(
const std::vector<vpImagePoint> &ip);
92 inline double getArea()
const {
return width * height; }
98 inline double getBottom()
const {
return (this->top + this->height - 1.0); }
108 bottomLeft.
set_u(getLeft());
109 bottomLeft.
set_v(getBottom());
121 bottomRight.
set_u(getRight());
122 bottomRight.
set_v(getBottom());
139 x = this->left + this->width / 2.0 - 0.5;
140 y = this->top + this->height / 2.0 - 0.5;
156 center.
set_u(this->left + this->width / 2.0 - 0.5);
157 center.
set_v(this->top + this->height / 2.0 - 0.5);
167 inline double getHeight()
const {
return this->height; }
174 inline double getLeft()
const {
return this->left; }
180 inline double getRight()
const {
return (this->left + this->width - 1.0); }
186 inline double getSize()
const {
return (this->width * this->height); }
193 inline double getTop()
const {
return this->top; }
203 topLeft.
set_u(getLeft());
204 topLeft.
set_v(getTop());
216 topRight.
set_u(getRight());
217 topRight.
set_v(getTop());
228 inline double getWidth()
const {
return this->width; }
235 bool operator==(
const vpRect &r)
const;
236 bool operator!=(
const vpRect &r)
const;
246 double x1 = (std::max)(left, r.left);
247 double y1 = (std::max)(top, r.top);
248 width = (std::min)(left + width, r.left + r.width) - x1;
249 height = (std::min)(top + height, r.top + r.height) - y1;
253 if (width <= 0 || height <= 0) {
274 friend VISP_EXPORT std::ostream &operator<<(std::ostream &os,
const vpRect &r);
276 void set(
double left,
double top,
double width,
double height);
277 void set(
const vpImagePoint &topLeft,
double width,
double height);
279 void set(
const vpRect &r);
280 void set(
const std::vector<vpImagePoint> &ip);
289 inline void setBottom(
double pos) { this->height = pos - this->top + 1.0; }
299 this->height = bottomRight.
get_v() - this->top + 1.0;
300 this->width = bottomRight.
get_u() - this->left + 1.0;
322 inline void setLeft(
double pos) { this->left = pos; }
334 inline void setRect(
double l,
double t,
double w,
double h)
349 inline void setRight(
double pos) { this->width = pos - this->left + 1.0; }
358 inline void setTop(
double pos) { this->top = pos; }
369 this->left = topLeft.
get_u();
370 this->top = topLeft.
get_v();
393 this->left = x - this->width / 2 + 0.5;
394 this->top = y - this->height / 2 + 0.5;
405 this->left = center.
get_u() - this->width / 2 + 0.5;
406 this->top = center.
get_v() - this->height / 2 + 0.5;
void getCenter(double &x, double &y) const
vpImagePoint getTopRight() const
vpImagePoint getTopLeft() const
vpImagePoint getBottomRight() const
void moveCenter(const vpImagePoint ¢er)
vpImagePoint getBottomLeft() const
void moveCenter(double x, double y)
void setTopLeft(const vpImagePoint &topLeft)
void setRight(double pos)
Defines a rectangle in the plane.
Class that defines a 2D point in an image. This class is useful for image processing and stores only ...
vpImagePoint getCenter() const
void setRect(double l, double t, double w, double h)
void setBottomRight(const vpImagePoint &bottomRight)
void setBottom(double pos)