35 #include <visp3/core/vpRectOriented.h>
41 : m_center(), m_width(), m_height(), m_theta(), m_topLeft(), m_topRight(), m_bottomLeft(), m_bottomRight()
56 m_topLeft.
set_i(m_center.
get_i() - m_height * cos(m_theta) / 2.0 - m_width * sin(m_theta) / 2.0);
57 m_topLeft.
set_j(m_center.
get_j() + m_height * sin(m_theta) / 2.0 - m_width * cos(m_theta) / 2.0);
58 m_bottomLeft.
set_i(m_center.
get_i() + m_height * cos(m_theta) / 2.0 - m_width * sin(m_theta) / 2.0);
59 m_bottomLeft.
set_j(m_center.
get_j() - m_height * sin(m_theta) / 2.0 - m_width * cos(m_theta) / 2.0);
60 m_bottomRight.
set_i(m_center.
get_i() + m_height * cos(m_theta) / 2.0 + m_width * sin(m_theta) / 2.0);
61 m_bottomRight.
set_j(m_center.
get_j() - m_height * sin(m_theta) / 2.0 + m_width * cos(m_theta) / 2.0);
62 m_topRight.
set_i(m_center.
get_i() - m_height * cos(m_theta) / 2.0 + m_width * sin(m_theta) / 2.0);
63 m_topRight.
set_j(m_center.
get_j() + m_height * sin(m_theta) / 2.0 + m_width * cos(m_theta) / 2.0);
75 m_topLeft.
set_i(m_center.
get_i() - m_height / 2.0);
76 m_topLeft.
set_j(m_center.
get_j() - m_width / 2.0);
77 m_bottomLeft.
set_i(m_center.
get_i() + m_height / 2.0);
78 m_bottomLeft.
set_j(m_center.
get_j() - m_width / 2.0);
79 m_bottomRight.
set_i(m_center.
get_i() + m_height / 2.0);
80 m_bottomRight.
set_j(m_center.
get_j() + m_width / 2.0);
81 m_topRight.
set_i(m_center.
get_i() - m_height / 2.0);
82 m_topRight.
set_j(m_center.
get_j() + m_width / 2.0);
94 m_topLeft.
set_i(m_center.
get_i() - m_height / 2.0);
95 m_topLeft.
set_j(m_center.
get_j() - m_width / 2.0);
96 m_bottomLeft.
set_i(m_center.
get_i() + m_height / 2.0);
97 m_bottomLeft.
set_j(m_center.
get_j() - m_width / 2.0);
98 m_bottomRight.
set_i(m_center.
get_i() + m_height / 2.0);
99 m_bottomRight.
set_j(m_center.
get_j() + m_width / 2.0);
100 m_topRight.
set_i(m_center.
get_i() - m_height / 2.0);
101 m_topRight.
set_j(m_center.
get_j() + m_width / 2.0);
109 if (std::fabs(m_theta) > std::numeric_limits<double>::epsilon())
112 return vpRect(m_topLeft, m_bottomRight);
123 m_bottomLeft = bottomLeft;
124 m_bottomRight = bottomRight;
125 m_topRight = topRight;
128 m_width = sqrt((m_topRight.
get_i() - m_topLeft.
get_i()) * (m_topRight.
get_i() - m_topLeft.
get_i()) +
130 m_height = sqrt((m_bottomLeft.
get_i() - m_topLeft.
get_i()) * (m_bottomLeft.
get_i() - m_topLeft.
get_i()) +
132 m_theta = atan2(m_topRight.
get_i() - m_topLeft.
get_i(), m_topRight.
get_j() - m_topLeft.
get_j());
138 m_topLeft += center - m_center;
139 m_bottomLeft += center - m_center;
140 m_bottomRight += center - m_center;
141 m_topRight += center - m_center;
165 m_topLeft.
set_i(m_center.
get_i() - m_height * cos(m_theta) / 2.0 - m_width * sin(m_theta) / 2);
166 m_topLeft.
set_j(m_center.
get_j() + m_height * sin(m_theta) / 2.0 - m_width * cos(m_theta) / 2);
167 m_bottomLeft.
set_i(m_center.
get_i() + m_height * cos(m_theta) / 2.0 - m_width * sin(m_theta) / 2);
168 m_bottomLeft.
set_j(m_center.
get_j() - m_height * sin(m_theta) / 2.0 - m_width * cos(m_theta) / 2);
169 m_bottomRight.
set_i(m_center.
get_i() + m_height * cos(m_theta) / 2.0 + m_width * sin(m_theta) / 2);
170 m_bottomRight.
set_j(m_center.
get_j() - m_height * sin(m_theta) / 2.0 + m_width * cos(m_theta) / 2);
171 m_topRight.
set_i(m_center.
get_i() - m_height * cos(m_theta) / 2.0 + m_width * sin(m_theta) / 2);
172 m_topRight.
set_j(m_center.
get_j() + m_height * sin(m_theta) / 2.0 + m_width * cos(m_theta) / 2);
185 m_topLeft.
set_i(m_center.
get_i() - m_height * cos(m_theta) / 2.0 - m_width * sin(m_theta) / 2);
186 m_topLeft.
set_j(m_center.
get_j() + m_height * sin(m_theta) / 2.0 - m_width * cos(m_theta) / 2);
187 m_bottomLeft.
set_i(m_center.
get_i() + m_height * cos(m_theta) / 2.0 - m_width * sin(m_theta) / 2);
188 m_bottomLeft.
set_j(m_center.
get_j() - m_height * sin(m_theta) / 2.0 - m_width * cos(m_theta) / 2);
189 m_bottomRight.
set_i(m_center.
get_i() + m_height * cos(m_theta) / 2.0 + m_width * sin(m_theta) / 2);
190 m_bottomRight.
set_j(m_center.
get_j() - m_height * sin(m_theta) / 2.0 + m_width * cos(m_theta) / 2);
191 m_topRight.
set_i(m_center.
get_i() - m_height * cos(m_theta) / 2.0 + m_width * sin(m_theta) / 2);
192 m_topRight.
set_j(m_center.
get_j() + m_height * sin(m_theta) / 2.0 + m_width * cos(m_theta) / 2);
201 if (!isLeft(point, m_topLeft, m_bottomLeft))
203 if (!isLeft(point, m_bottomLeft, m_bottomRight))
205 if (!isLeft(point, m_bottomRight, m_topRight))
207 if (!isLeft(point, m_topRight, m_topLeft))
217 double c = -(a * point1.
get_i() + b * point1.
get_j());
218 double d = a * pointToTest.
get_i() + b * pointToTest.
get_j() + c;
error that can be emitted by ViSP classes.
@ badValue
Used to indicate that a value is not in the allowed range.
Class that defines a 2D point in an image. This class is useful for image processing and stores only ...
Defines an oriented rectangle in the plane.
double getHeight() const
Get the rectangle height.
vpImagePoint getBottomLeft() const
Get the bottom-left corner.
double getOrientation() const
Get the rectangle orientation (rad).
vpImagePoint getBottomRight() const
Get the bottom-right corner.
void setPoints(const vpImagePoint &topLeft, const vpImagePoint &topRight, const vpImagePoint &bottomLeft, const vpImagePoint &bottomRight)
void setCenter(const vpImagePoint ¢er)
Set the center of the rectangle.
double getWidth() const
Get the rectangle width.
bool isInside(const vpImagePoint &point) const
Check whether the point is inside the rectangle.
vpRectOriented()
Default constructor.
void setSize(double width, double height)
Set the size of the rectangle : performs a homothety relatively to the rectangle center.
vpImagePoint getTopRight() const
Get the top-right corner.
vpImagePoint getTopLeft() const
Get the top-left corner.
vpImagePoint getCenter() const
Get the rectangle center point.
vpRectOriented & operator=(const vpRectOriented &rect)=default
void setOrientation(double theta)
Set the rectangle orientation (rad).
Defines a rectangle in the plane.
void getCenter(double &x, double &y) const