ViSP  2.8.0
vpRect Class Reference

#include <vpRect.h>

Public Member Functions

 vpRect ()
 
 vpRect (double left, double top, double width, double height)
 
 vpRect (const vpImagePoint &topLeft, double width, double height)
 
 vpRect (const vpImagePoint &topLeft, const vpImagePoint &bottomRight)
 
 vpRect (const vpRect &r)
 
vpRectoperator= (const vpRect &r)
 
double getBottom () const
 
vpImagePoint getBottomRight () const
 
void getCenter (double &x, double &y) const
 
vpImagePoint getCenter () const
 
double getHeight () const
 
double getLeft () const
 
double getRight () const
 
double getTop () const
 
vpImagePoint getTopLeft () const
 
double getWidth () const
 
void setBottom (double pos)
 
void setBottomRight (const vpImagePoint &bottomRight)
 
void setHeight (double h)
 
void setLeft (double pos)
 
void setRect (double left, double top, double width, double height)
 
void setRight (double pos)
 
void setTop (double pos)
 
void setTopLeft (const vpImagePoint &topLeft)
 
void setWidth (double w)
 
void moveCenter (double x, double y)
 

Detailed Description

Defines a rectangle in the plane.

A rectangle is internally represented as an upper-left corner and a width and height, but it is normally expressed as an upper-left corner and bottom-right corner.

Note that the size (width and height) of a rectangle might be different from what you are used to. If the top-left corner and the bottom-right corner are the same, the height and the width of the rectangle will both be 1.

Generally, width = right - left + 1 and height = bottom - top +

  1. We designed it this way to make it correspond to rectangular spaces used by drawing functions in which the width and height denote a number of pixels. For example, drawing a rectangle with width and height 1 draws a single pixel.

The default coordinate system has origin (0, 0) in the top-left corner. The positive direction of the y axis is down, and the positive x axis is from left to right.

A vpRect can be constructed with a set of left, top, width and height double. After creation the dimensions can be changed, e.g. with setLeft(), setRight(), setTop() and setBottom(), or by setting sizes, e.g. setWidth(), setHeight()

Examples:
fernClassifier.cpp, planarObjectDetector.cpp, testCreateSubImage.cpp, and testDisplays.cpp.

Definition at line 82 of file vpRect.h.

Constructor & Destructor Documentation

vpRect::vpRect ( )

Constructs a default rectangle with the top, left corner set to (0,0) and width and height set to 1.

Definition at line 59 of file vpRect.cpp.

vpRect::vpRect ( double  left,
double  top,
double  width,
double  height 
)

Constructs a rectangle with the top, left corner and width and height.

Definition at line 73 of file vpRect.cpp.

vpRect::vpRect ( const vpImagePoint topLeft,
double  width,
double  height 
)

Constructs a rectangle with topLeft the top-left corner location and width and height the rectangle size.

Definition at line 87 of file vpRect.cpp.

References vpImagePoint::get_u(), and vpImagePoint::get_v().

vpRect::vpRect ( const vpImagePoint topLeft,
const vpImagePoint bottomRight 
)

Constructs a rectangle with topLeft the top-left corner location and bottomRight the bottom-right corner.

Definition at line 101 of file vpRect.cpp.

References vpImagePoint::get_u(), vpImagePoint::get_v(), setBottom(), and setRight().

vpRect::vpRect ( const vpRect r)

Constructs a rectangle that is a copy of r.

Definition at line 115 of file vpRect.cpp.

Member Function Documentation

double vpRect::getBottom ( ) const
inline

Returns the bottom coordinate of the rectangle.

See also
getRight()

Definition at line 98 of file vpRect.h.

Referenced by vpImageTools::createSubImage(), vpDisplayOpenCV::displayRectangle(), vpImageSimulator::getImage(), vpImagePoint::inRectangle(), and vpDot2::searchDotsInArea().

vpImagePoint vpRect::getBottomRight ( ) const
inline

Returns the bottom-right coordinate of the rectangle.

See also
getTopLeft(), getBottom(), getRight()

Definition at line 103 of file vpRect.h.

References vpImagePoint::set_u(), and vpImagePoint::set_v().

void vpRect::getCenter ( double &  x,
double &  y 
) const
inline

Returns the center point of the rectangle. The center point coordinates are (x, y)

The default coordinate system has origin (0, 0) in the top-left corner. The positive direction of the y axis is down, and the positive x axis is from left to right.

See also
moveCenter()

Definition at line 121 of file vpRect.h.

vpImagePoint vpRect::getCenter ( ) const
inline

Returns the center point of the rectangle. The center point coordinates are (x, y)

The default coordinate system has origin (0, 0) in the top-left corner. The positive direction of the y axis is down, and the positive x axis is from left to right.

See also
moveCenter()

Definition at line 136 of file vpRect.h.

References vpImagePoint::set_u(), and vpImagePoint::set_v().

double vpRect::getHeight ( ) const
inline
double vpRect::getRight ( ) const
inline

Returns the right coordinate of the rectangle.

See also
getLeft()

Definition at line 162 of file vpRect.h.

Referenced by vpImageTools::createSubImage(), vpDisplayOpenCV::displayRectangle(), vpImageSimulator::getImage(), vpImagePoint::inRectangle(), and vpDot2::searchDotsInArea().

vpImagePoint vpRect::getTopLeft ( ) const
inline

Returns the top-left position of the rectangle.

See also
getBottomRight(), getTop(), getLeft()

Definition at line 175 of file vpRect.h.

References vpImagePoint::set_u(), and vpImagePoint::set_v().

Referenced by vpPlanarObjectDetector::buildReference(), and vpDisplay::flushROI().

void vpRect::moveCenter ( double  x,
double  y 
)
inline

Sets the center point of the rectangle to (x, y), leaving the size unchanged.

See also
getCenter()

Definition at line 288 of file vpRect.h.

vpRect & vpRect::operator= ( const vpRect r)

Assign r to this rectangle and return a reference to this rectangle.

Definition at line 127 of file vpRect.cpp.

void vpRect::setBottom ( double  pos)
inline

Sets the bottom edge position of the rectangle to pos. May change the height of the rectangle, but will never change the top edge position the rectangle.

See also
setTop()

Definition at line 198 of file vpRect.h.

Referenced by vpRect().

void vpRect::setBottomRight ( const vpImagePoint bottomRight)
inline

Sets the bottom-right position of the rectangle. Will never change the top-left position the rectangle.

See also
setTopLeft()

Definition at line 206 of file vpRect.h.

References vpImagePoint::get_u(), and vpImagePoint::get_v().

Referenced by vpPolygon::updateBoundingBox().

void vpRect::setHeight ( double  h)
inline

Sets the height of the rectangle to h. The top edge is not moved, but the bottom edge may be moved.

See also
setWidth()
Examples:
testCreateSubImage.cpp.

Definition at line 217 of file vpRect.h.

void vpRect::setLeft ( double  pos)
inline

Sets the left edge position of the rectangle to pos. May change the right edge position of the rectangle, but will never change the width of the rectangle.

See also
setRight()
Examples:
testCreateSubImage.cpp.

Definition at line 227 of file vpRect.h.

void vpRect::setRect ( double  left,
double  top,
double  width,
double  height 
)
inline

Sets the coordinates of the rectangle's top left corner to (left, top), and its size to (width, height).

Definition at line 234 of file vpRect.h.

Referenced by vpDot2::getBBox(), and vpDot::getBBox().

void vpRect::setRight ( double  pos)
inline

Sets the right edge position of the rectangle to pos. May change the width of the rectangle, but will never change the left edge position of the rectangle.

See also
setLeft()

Definition at line 249 of file vpRect.h.

Referenced by vpRect().

void vpRect::setTop ( double  pos)
inline

Sets the top edge position of the rectangle to pos. May change the bottom edge position of the rectangle, but will never change the height of the rectangle.

See also
setBottom()
Examples:
testCreateSubImage.cpp.

Definition at line 258 of file vpRect.h.

void vpRect::setTopLeft ( const vpImagePoint topLeft)
inline

Sets the top-left position of the rectangle. May change the bottom edge position of the rectangle, but will never change the height of the rectangle.

See also
setBottomRight()

Definition at line 267 of file vpRect.h.

References vpImagePoint::get_u(), and vpImagePoint::get_v().

Referenced by vpPolygon::updateBoundingBox().

void vpRect::setWidth ( double  w)
inline

Sets the width of the rectangle to w. The right edge is changed, but not the left edge.

See also
setHeight()
Examples:
testCreateSubImage.cpp.

Definition at line 278 of file vpRect.h.