C3D Toolkit  Kernel - 117982, Vision - 2.9.2.2
VSN::RectF Class Reference

RectF class defines rectangle in the plane using float-precision. More...

#include <vsn_rect.h>

Public Member Functions

 RectF ()
 Default constructor for creating empty rectangle.
 
void Init (float x, float y, float w, float h)
 Initializes the rectangle with setting top-left angle coordinates and rectangle size.
 
void InitCoords (float x1, float y1, float x2, float y2)
 Initializes the rectangle with setting top-left angle coordinates and rectangle size.
 
bool IsNull () const
 True if rectangle is empty. More...
 
RectF Normalized () const
 Returns normalized rectangle, i.e. the rectangle has no negative width and height. More...
 
PointF GetTopLeft () const
 Returns position of the top-left rectangle angle. More...
 
void SetTopLeft (const PointF &p)
 Sets the top-left rectangle angle to the given position. Changes size, but it does not change the bottom-right rectangle angle.
 
void SetBottomRight (const PointF &p)
 Sets the bottom-right rectangle angle to the given position. Changes size, but it does not change the top-left rectangle angle.
 
void Offset (float dx, float dy)
 Moves the rectangle on "dx" value along X-axis and "dy" value along Y-axis. It is all about the current position.
 
void Offset (const PointF &p)
 Overloaded function. It moves the rectangle p.GetX() along X-axis and p.GetY() along Y-axis, all about the current position.
 
RectF Offseted (float dx, float dy) const
 Returns copy of the rectangle that is moved on "dx" value along X-axis and "dy" value along Y-axis, all about the current position. All positive values move the rectangle to right and down. More...
 
RectF Offseted (const PointF &p) const
 Overloaded function. It returns copy of the rectangle that is moved p.GetX() along X-axis and p.GetY() along Y-axis, all about the current position. Positive values move the rectangle to right and down. More...
 
void MoveToXY (float x, float y)
 Moves the rectangle by shifting the top-left angle at the defined position (х, у). Rectangle size is not changed.
 
void MoveToXY (const PointF &p)
 Moves the rectangle by shifting the top-left angle at the defined position.
 
void Inflate (float x1, float y1, float x2, float y2)
 Adds x1, y1, x2, and y2 values to existing rectangle coordinates.
 
RectF Inflated (float x1, float y1, float x2, float y2) const
 Returns new rectangle with x1, y1, x2, and y2 values, added to existing rectangle coordinates. More...
 
bool RectInRect (const RectF &other) const
 Overloaded function. True if the defined rectangle is inside the given rectangle. True if the defined rectangle is wholly inside the given rectangle, not on the edge. More...
 
bool PntInRect (const PointF &p) const
 True if the given point is inside the rectangle or on the edge. True if the given point is inside the rectangle, i.e. not on the edge. More...
 
bool PntInRect (float x, float y) const
 Overloaded function. True if point (х, у) is inside the rectangle. More...
 
RectF United (const RectF &other) const
 Returns bounding rectangle of the given rectangle and the defined rectangle. More...
 
RectF Intersected (const RectF &other) const
 Returns intersection of the given rectangle and the defined rectangle. More...
 
bool Intersects (const RectF &other) const
 True if the given rectangle intersects with the defined rectangle. It means that at least one pixel, inside both rectangles, exists. More...
 

Detailed Description

RectF class defines rectangle in the plane using float-precision.

Rectangle is typically expressed as top-left angle and size. Rectangle can be constructed with integer coordinates of left, top, width and height, or with PointF and SizeI classes. RectI class provides a set of functions that return necessary coordinates of the rectangle and allow initializing them. RectI class also provides functions for moving the rectangle about its coordinates, etc.

Member Function Documentation

◆ IsNull()

bool VSN::RectF::IsNull ( ) const
inline

True if rectangle is empty.

Null rectangle has width and height that equal 0, i.e. GetRight() == GetLeft() - 1 и GetBottom() == GetTop() - 1. Null rectangle is also empty and hence not valid.

Returns
True if rectangle is empty.

◆ Normalized()

RectF VSN::RectF::Normalized ( ) const

Returns normalized rectangle, i.e. the rectangle has no negative width and height.

Note
If GetWidth() < 0, then function swaps the left and right angles. If GetHeight() < 0, then it swaps the top and bottom angles.
Returns
Normalized rectangle.

◆ GetTopLeft()

PointF VSN::RectF::GetTopLeft ( ) const
inline

Returns position of the top-left rectangle angle.

Returns
Position of the top-left rectangle angle.

◆ Offseted() [1/2]

RectF VSN::RectF::Offseted ( float  dx,
float  dy 
) const
inline

Returns copy of the rectangle that is moved on "dx" value along X-axis and "dy" value along Y-axis, all about the current position. All positive values move the rectangle to right and down.

Returns
New rectangle.

◆ Offseted() [2/2]

RectF VSN::RectF::Offseted ( const PointF p) const
inline

Overloaded function. It returns copy of the rectangle that is moved p.GetX() along X-axis and p.GetY() along Y-axis, all about the current position. Positive values move the rectangle to right and down.

Returns
New rectangle.

◆ Inflated()

RectF VSN::RectF::Inflated ( float  x1,
float  y1,
float  x2,
float  y2 
) const
inline

Returns new rectangle with x1, y1, x2, and y2 values, added to existing rectangle coordinates.

Returns
New rectangle.

◆ RectInRect()

bool VSN::RectF::RectInRect ( const RectF other) const

Overloaded function. True if the defined rectangle is inside the given rectangle. True if the defined rectangle is wholly inside the given rectangle, not on the edge.

Returns
True if the defined rectangle is inside the given rectangle.

◆ PntInRect() [1/2]

bool VSN::RectF::PntInRect ( const PointF p) const

True if the given point is inside the rectangle or on the edge. True if the given point is inside the rectangle, i.e. not on the edge.

Returns
True if the given point is inside the rectangle or on the edge.

◆ PntInRect() [2/2]

bool VSN::RectF::PntInRect ( float  x,
float  y 
) const

Overloaded function. True if point (х, у) is inside the rectangle.

Returns
True if point (х, у) is inside the rectangle.

◆ United()

RectF VSN::RectF::United ( const RectF other) const

Returns bounding rectangle of the given rectangle and the defined rectangle.

Returns
Bounding rectangle of the given rectangle and the defined rectangle.

◆ Intersected()

RectF VSN::RectF::Intersected ( const RectF other) const

Returns intersection of the given rectangle and the defined rectangle.

Returns
Bounding rectangle of the given rectangle and the defined rectangle.

◆ Intersects()

bool VSN::RectF::Intersects ( const RectF other) const

True if the given rectangle intersects with the defined rectangle. It means that at least one pixel, inside both rectangles, exists.

Returns
True if the given rectangle intersects with the defined rectangle.

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