C3D Toolkit  Kernel - 117982, Vision - 2.9.2.2

Bounding rectangle. More...

#include <mb_rect.h>

Public Member Functions

 MbRect ()
 Constructor of an empty bounding box.
 
 MbRect (double _left, double _bottom, double _right, double _top)
 Constructor by given bounds.
 
 MbRect (const MbRect &r)
 Constructor by another bounding box.
 
 MbRect (const MbCartPoint &p1, const MbCartPoint &p2, bool normalize=true)
 The constructor by two diagonal points.
 
 MbRect (const MbRect &r, const MbMatrix &m)
 Constructor by bounding box with subsequent transformation by the matrix.
 
 MbRect (const MbRect2D &r)
 Constructor by bounding box MbRect2D.
 
void Set (double _left, double _bottom, double _right, double _top)
 Set given values of bounds.
 
void Set (const MbRect &)
 Set given values of bounds.
 
void Set (const MbRect2D &)
 Set given values of bounds.
 
void Set (const MbCartPoint &p1, const MbCartPoint &p2)
 Set given values of bounds.
 
void Set (const MbCartPoint &p, double eps)
 Set values of bounds as point neighborhood.
 
void Set (const MbCartPoint &p, double dx, double dy)
 Set values of bounds as point neighborhood.
 
void SetNull ()
 Set to zero.
 
void SetEmpty ()
 Set empty ("everted").
 
bool IsEmpty () const
 Check for emptiness.
 
bool IsDegenerateX () const
 Check bounding box for degeneracy by X-axis.
 
bool IsDegenerateY () const
 Check bounding box for degeneracy by Y-axis.
 
bool IsSame (const MbRect &, double eps) const
 Check bounding boxes for equality.
 
bool IsSame (const MbRect &, double xeps, double yeps) const
 Check bounding boxes for equality.
 
bool operator== (const MbRect &other) const
 Check bounding boxes for equality.
 
bool operator!= (const MbRect &other) const
 Check bounding boxes for inequality.
 
void operator= (const MbRect &other)
 Assign a value of another bounding box.
 
double GetTop () const
 Get top bound.
 
double GetBottom () const
 Get bottom bound.
 
double GetLeft () const
 Get left bound.
 
double GetRight () const
 Get right bound.
 
void SetTop (double _top)
 Set top bound.
 
void SetBottom (double _bottom)
 Set bottom bound.
 
void SetLeft (double _left)
 Set left bound.
 
void SetRight (double _right)
 Set right bound.
 
double GetXMin () const
 Get minimum by X.
 
double GetYMin () const
 Get minimum by Y.
 
double GetXMax () const
 Get maximum by X.
 
double GetYMax () const
 Get maximum by Y.
 
double GetXMid () const
 Get middle by X.
 
double GetYMid () const
 Get middle by Y.
 
void SetXMin (double s)
 Set minimum by X.
 
void SetYMin (double s)
 Set maximum by X.
 
void SetXMax (double s)
 Set minimum by Y. More...
 
double Width () const
 Find width of bounding box.
 
double Height () const
 Find height of bounding box.
 
double GetLengthX () const
 Get length by X.
 
double GetLengthY () const
 Get length by Y.
 
double GetLength (double eps) const
 Get half of perimeter.
 
double GetSquare (double eps) const
 Get area.
 
double GetDiagonal () const
 Get the diagonal length.
 
bool Intersection (const MbRect &rect1, const MbRect &rect2, double eps=Math::LengthEps)
 Calculate bounding box of two bounding boxes intersection.
 
bool Union (const MbRect &rect1, const MbRect &rect2)
 Calculate bounding box enclosing two bounding boxes.
 
bool Contains (const MbCartPoint &p, double eps=Math::LengthEps) const
 Check if the bounding box contains the given point.
 
bool Contains (double x, double y, double eps=Math::LengthEps) const
 Check if the bounding box contains the given point.
 
bool Contains (const MbCartPoint &p, double xeps, double yeps) const
 Check if the bounding box contains the given point.
 
bool Contains (double x, double y, double xeps, double yeps) const
 Check if the bounding box contains the given point.
 
bool ContainsX (double x, double eps=Math::LengthEps) const
 Check if the bounding box contains the given X coordinate.
 
bool ContainsY (double y, double eps=Math::LengthEps) const
 Check if the bounding box contains the given Y coordinate.
 
void OutCodes (const MbCartPoint &p, unsigned int &outcodes, double eps=METRIC_PRECISION) const
 Calculate the codes of a point location relative to the rectangle.
 
double DistanceToPoint (const MbCartPoint &point) const
 Calculate the distance to the nearest boundary of the bounding box. More...
 
double DistanceToPoint (const MbCartPoint &to, uint &outcodes) const
 Calculate the distance to a point.
 
double DistanceToPoint2 (const MbCartPoint &pnt) const
 Calculate the square of distance to a point.
 
double DistanceToCube (const MbRect &cube, double eps=Math::metricRegion) const
 Calculate the distance to the cube. More...
 
void CalcDistances (const MbCartPoint &to, double &dmin, double &dmax, uint &outcodes) const
 Calculate minimal and maximal distances to a point.
 
bool Intersect (const MbRect &, TaeTwoRectPos &) const
 Whether the bounding box intersects with another bounding box with intersection attribute.
 
bool Intersect (const MbRect &other, double eps=Math::LengthEps) const
 Whether the bounding box intersects with another bounding box.
 
bool Intersect (const MbRect &other, double xeps, double yeps) const
 Whether the bounding box intersects with another bounding box.
 
MbRect CompressedBy (double dLeft, double dBottom, double dRight, double dTop) const
 Create new rectangle from the current one by shrinking.
 
MbRectNormalize ()
 Normalize oneself.
 
void Transform (const MbMatrix &)
 Transform by matrix.
 
void Scale (double sx, double sy)
 Scale.
 
MbRectoperator|= (const MbRect &)
 Enclose a rectangle.
 
MbRectoperator|= (const MbCartPoint &)
 Enclose a point.
 
MbRectoperator|= (const MbHomogeneous &)
 Enclose a point.
 
MbRectoperator|= (const SArray< MbCartPoint > &)
 Enclose an array of points.
 
MbRectoperator|= (const SArray< MbHomogeneous > &)
 Enclose an array of points.
 
void Include (double x, double y)
 Enclose a point specified as XY.
 
void IncludeX (double x)
 Enclose an X-coordinate.
 
void IncludeY (double y)
 Enclose an Y-coordinate.
 
void IncludeXInterval (double x, double dx)
 Enclose a range from X - dx to X + dx.
 
void IncludeYInterval (double y, double dy)
 Enclose a range from Y - dy to Y + dy.
 
void Move (const MbVector &to)
 Move rectangle.
 
void Move (double dx, double dy)
 Move rectangle.
 
void Scale (double scale)
 Scale relative to 0.
 
void Scale (const MbCartPoint &point, double scale)
 Scale relative to point.
 
void Enlarge (double x, double y)
 Extend rectangle.
 
void Enlarge (double delta)
 Extend rectangle in all directions.
 
void GetOusideRect (MbRect &r) const
 Get the covering rectangle.
 
void GetCenter (MbCartPoint &p) const
 Get center of the bounding box.
 
size_t GetVerticesCount () const
 Get count of vertices.
 
void GetVertex (size_t index, MbCartPoint &p) const
 Get vertex of bounding rectangle by index in range from 0 to 3.
 
const MbRectGetRect () const
 Get reference to itself.
 
double GetMin (size_t k) const
 Access to a coordinate by an index.
 
double GetMax (size_t k) const
 Access to a coordinate by an index.
 
double GetSideLength (size_t k) const
 Get side length.
 
const MbRectGetCube () const
 Get reference to itself.
 

Static Public Member Functions

static size_t GetDimension ()
 The number of point coordinates.
 

Public Attributes

double left
 Left bound of bounding box.
 
double bottom
 Bottom bound of bounding box.
 
double right
 Right bound of bounding box.
 
double top
 Top bound of bounding box.
 

Detailed Description

Bounding rectangle.

Bounding box in two-dimensional space.
Used for fast estimation of two-dimensional objects proximity.

Member Function Documentation

◆ SetXMax()

void MbRect::SetXMax ( double  s)
inline

Set minimum by Y.

Set maximum by Y.

◆ DistanceToPoint()

double MbRect::DistanceToPoint ( const MbCartPoint point) const
inline

Calculate the distance to the nearest boundary of the bounding box.

The calculated distance is negative if the point is inside, and is positive if it is outside.

Parameters
[in]point- The investigated point.
Returns
Returns the distance to the boundary.

◆ DistanceToCube()

double MbRect::DistanceToCube ( const MbRect cube,
double  eps = Math::metricRegion 
) const

Calculate the distance to the cube.

It returns zero if the cubes intersect or one is contained in the other.

Parameters
[in]cube- Other cube.
[in]eps- A metric tolerance.
Returns
Returns the distance to the boundary.

The documentation for this class was generated from the following file: