The blo Library
Loading...
Searching...
No Matches
Public Member Functions | List of all members
blo::Rectangle< T > Class Template Reference

Rectangle. More...

#include <Rectangle.h>

Public Member Functions

 Rectangle ()=default
 Default constructor.
 
 Rectangle (const T &x1, const T &y1, const T &x2, const T &y2)
 Constructs rectangle from the coordinates of two points.
 
 Rectangle (const Point< T, 2 > &point1, const Point< T, 2 > &point2)
 Constructs rectangle from two points.
 
 Rectangle (const Rectangle< T > &rhs)=default
 Copy constructor.
 
virtual ~Rectangle ()=default
 Destructor.
 
Rectangle< T > & operator= (const Rectangle< T > &rhs)=default
 Assignment operator.
 
bool empty () const
 Tests if the rectangle is empty.
 
void clear ()
 Resizes rectangle to zero width and zero height.
 
void coords (T &x1, T &y1, T &x2, T &y2) const
 Retrieves coordinates of the two points that define the rectangle.
 
void points (Point< T, 2 > &point1, Point< T, 2 > &point2) const
 Retrieves the two points that define the rectangle.
 
void setCoords (const T &x1, const T &y1, const T &x2, const T &y2)
 Sets coordinates of the two points that define the rectangle.
 
void setPoints (const Point< T, 2 > &point1, const Point< T, 2 > &point2)
 Sets the two points that define the rectangle.
 
const T x1 () const
 Retrieves the x coordinate of the first point that defines the rectangle.
 
const T y1 () const
 Retrieves the y coordinate of the first point that defines the rectangle.
 
const T x2 () const
 Retrieves the x coordinate of the second point that defines the rectangle.
 
const T y2 () const
 Retrieves the y coordinate of the second point that defines the rectangle.
 
const Point< T, 2 > point1 () const
 Retrieves the first point that defines the rectangle.
 
const Point< T, 2 > point2 () const
 Retrieves the second point that defines the rectangle.
 
const T width () const
 Width of the rectangle.
 
const T height () const
 Height of the rectangle.
 

Detailed Description

template<typename T>
class blo::Rectangle< T >

Rectangle.

Template Parameters
TData type.

A rectangle defined by the two points point1 = (x1, y1)^T and point2 = (x2, y2)^T. The point (x, y)^T is in the rectangle if x1 <= x < x2 and y1 <= y < y2.

Note
point1 = (x1, y1)^T is in the rectangle. point2 = (x2, y2)^T is not in the rectangle.

Constructor & Destructor Documentation

◆ Rectangle() [1/4]

template<typename T >
blo::Rectangle< T >::Rectangle ( )
default

Default constructor.

◆ Rectangle() [2/4]

template<typename T >
blo::Rectangle< T >::Rectangle ( const T &  x1,
const T &  y1,
const T &  x2,
const T &  y2 
)

Constructs rectangle from the coordinates of two points.

Parameters
x1,y1Coordinates of the first point.
x2,y2Coordinates of the second point.

◆ Rectangle() [3/4]

template<typename T >
blo::Rectangle< T >::Rectangle ( const Point< T, 2 > &  point1,
const Point< T, 2 > &  point2 
)

Constructs rectangle from two points.

Parameters
point1The first point.
point2The second point.

◆ Rectangle() [4/4]

template<typename T >
blo::Rectangle< T >::Rectangle ( const Rectangle< T > &  rhs)
default

Copy constructor.

◆ ~Rectangle()

template<typename T >
virtual blo::Rectangle< T >::~Rectangle ( )
virtualdefault

Destructor.

Member Function Documentation

◆ clear()

template<typename T >
void blo::Rectangle< T >::clear ( )

Resizes rectangle to zero width and zero height.

◆ coords()

template<typename T >
void blo::Rectangle< T >::coords ( T &  x1,
T &  y1,
T &  x2,
T &  y2 
) const

Retrieves coordinates of the two points that define the rectangle.

point1 = (x1, y1)^T and point2 = (x2, y2)^T, where x1 <= x2 and y1 <= y2.

Parameters
x1,y1Coordinates of the first point.
x2,y2Coordinates of the second point.

◆ empty()

template<typename T >
bool blo::Rectangle< T >::empty ( ) const

Tests if the rectangle is empty.

Returns
true if rectangle is empty, false otherwise.

◆ height()

template<typename T >
const T blo::Rectangle< T >::height ( ) const

Height of the rectangle.

Returns
Height of the rectangle.

◆ operator=()

template<typename T >
Rectangle< T > & blo::Rectangle< T >::operator= ( const Rectangle< T > &  rhs)
default

Assignment operator.

◆ point1()

template<typename T >
const Point< T, 2 > blo::Rectangle< T >::point1 ( ) const

Retrieves the first point that defines the rectangle.

point1 = (x1, y1)^T and point2 = (x2, y2)^T, where x1 <= x2 and y1 <= y2.

Returns
The first point.

◆ point2()

template<typename T >
const Point< T, 2 > blo::Rectangle< T >::point2 ( ) const

Retrieves the second point that defines the rectangle.

point1 = (x1, y1)^T and point2 = (x2, y2)^T, where x1 <= x2 and y1 <= y2.

Returns
The second point.

◆ points()

template<typename T >
void blo::Rectangle< T >::points ( Point< T, 2 > &  point1,
Point< T, 2 > &  point2 
) const

Retrieves the two points that define the rectangle.

point1 = (x1, y1)^T and point2 = (x2, y2)^T, where x1 <= x2 and y1 <= y2.

Parameters
point1The first point.
point2The second point.

◆ setCoords()

template<typename T >
void blo::Rectangle< T >::setCoords ( const T &  x1,
const T &  y1,
const T &  x2,
const T &  y2 
)

Sets coordinates of the two points that define the rectangle.

Parameters
x1,y1Coordinates of the first point.
x2,y2Coordinates of the second point.

◆ setPoints()

template<typename T >
void blo::Rectangle< T >::setPoints ( const Point< T, 2 > &  point1,
const Point< T, 2 > &  point2 
)

Sets the two points that define the rectangle.

Parameters
point1The first point.
point2The second point.

◆ width()

template<typename T >
const T blo::Rectangle< T >::width ( ) const

Width of the rectangle.

Returns
Width of the rectangle.

◆ x1()

template<typename T >
const T blo::Rectangle< T >::x1 ( ) const

Retrieves the x coordinate of the first point that defines the rectangle.

point1 = (x1, y1)^T and point2 = (x2, y2)^T, where x1 <= x2 and y1 <= y2.

Returns
x coordinate of the first point.

◆ x2()

template<typename T >
const T blo::Rectangle< T >::x2 ( ) const

Retrieves the x coordinate of the second point that defines the rectangle.

point1 = (x1, y1)^T and point2 = (x2, y2)^T, where x1 <= x2 and y1 <= y2.

Returns
x coordinate of the second point.

◆ y1()

template<typename T >
const T blo::Rectangle< T >::y1 ( ) const

Retrieves the y coordinate of the first point that defines the rectangle.

point1 = (x1, y1)^T and point2 = (x2, y2)^T, where x1 <= x2 and y1 <= y2.

Returns
y coordinate of the first point.

◆ y2()

template<typename T >
const T blo::Rectangle< T >::y2 ( ) const

Retrieves the y coordinate of the second point that defines the rectangle.

point1 = (x1, y1)^T and point2 = (x2, y2)^T, where x1 <= x2 and y1 <= y2.

Returns
y coordinate of the second point.

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