ULIS  dev4.0.7
Utility Library for Imaging Systems
Public Member Functions | Static Public Member Functions | Public Attributes | Static Public Attributes | List of all members
TRectangle< T > Class Template Reference

The TRectangle class provides a simple 2D rectangle class for box geometry applications. More...

Public Member Functions

 TRectangle ()
 
template<typename U >
 TRectangle (const TRectangle< U > &iOther)
 
 TRectangle (T iX, T iY, T iW, T iH)
 
Area () const
 
void Exclusion (const TRectangle< T > &iOther, TArray< TRectangle< T > > *oResult) const
 
bool HitTest (const TVector2< T > &iV) const
 
bool InHorizontalRange (T iV) const
 
bool InVerticalRange (T iV) const
 
bool operator!= (const TRectangle< T > &iOther) const
 
TRectangle< T > operator& (const TRectangle< T > &iOther) const
 
TRectangle< T > operator- (const TRectangle< T > &iOther) const
 
bool operator== (const TRectangle< T > &iOther) const
 
TRectangle< T > operator| (const TRectangle< T > &iOther) const
 
TVector2< T > Position () const
 
void Sanitize ()
 
TRectangle< T > Sanitized () const
 
TRectangle< T > & Shift (const TVector2< T > &iVec)
 
TVector2< T > Size () const
 
void TransformAffine (const FMat3F &iTransform)
 
TRectangle< T > TransformedAffine (const FMat3F &iTransform) const
 
TRectangle< T > TransformedPerspective (const FMat3F &iTransform) const
 
void TransformPerspective (const FMat3F &iTransform)
 
TRectangle< T > UnionLeaveEmpty (const TRectangle< T > &iOther) const
 

Static Public Member Functions

static TRectangle< T > FromMinMax (T iXMin, T iYMin, T iXMax, T iYMax)
 
static TRectangle< T > FromPositionAndSize (const TVector2< T > &iPos, const TVector2< T > &iSize)
 
static TRectangle< T > FromXYWH (T iX, T iY, T iW, T iH)
 

Public Attributes

h
 
w
 
x
 
y
 

Static Public Attributes

static const TRectangle Auto = TRectangle< T >( 0, 0, std::numeric_limits< T >::max(), std::numeric_limits< T >::max() )
 

Detailed Description

template<typename T>
class TRectangle< T >

The TRectangle class is a template class that provides basic 2D rectangle functionnalities, it can be used with any numeric types, ranging from integer values to floating point values.

The rectangle representation is stored as x, y, w, h.

Constructor & Destructor Documentation

◆ TRectangle() [1/3]

template<typename T>
TRectangle< T >::TRectangle ( )
inline

Default constructor, initializes values to zero.

◆ TRectangle() [2/3]

template<typename T>
TRectangle< T >::TRectangle ( iX,
iY,
iW,
iH 
)
inline

Constructor, from input values.

◆ TRectangle() [3/3]

template<typename T>
template<typename U >
TRectangle< T >::TRectangle ( const TRectangle< U > &  iOther)
inline

Construct the Rect from input Rect of any convertible type.

Member Function Documentation

◆ Area()

template<typename T>
T TRectangle< T >::Area ( ) const
inline

Return the area of the rect.

◆ Exclusion()

template<typename T>
void TRectangle< T >::Exclusion ( const TRectangle< T > &  iOther,
TArray< TRectangle< T > > *  oResult 
) const
inline

Compute exclude of this Rect with input Rect and return result array.

◆ FromMinMax()

template<typename T>
static TRectangle< T > TRectangle< T >::FromMinMax ( iXMin,
iYMin,
iXMax,
iYMax 
)
inlinestatic

Static named maker from min max input values.

◆ FromPositionAndSize()

template<typename T>
static TRectangle< T > TRectangle< T >::FromPositionAndSize ( const TVector2< T > &  iPos,
const TVector2< T > &  iSize 
)
inlinestatic

Static named maker from pos and size input values.

◆ FromXYWH()

template<typename T>
static TRectangle< T > TRectangle< T >::FromXYWH ( iX,
iY,
iW,
iH 
)
inlinestatic

Static named maker from input values.

◆ HitTest()

template<typename T>
bool TRectangle< T >::HitTest ( const TVector2< T > &  iV) const
inline

Collision test with TVector2.

◆ InHorizontalRange()

template<typename T>
bool TRectangle< T >::InHorizontalRange ( iV) const
inline

Horizontal collision test with x coordinate value.

◆ InVerticalRange()

template<typename T>
bool TRectangle< T >::InVerticalRange ( iV) const
inline

Vertical collision test with y coordinate value.

◆ operator!=()

template<typename T>
bool TRectangle< T >::operator!= ( const TRectangle< T > &  iOther) const
inline

Strict inequality comparison.

◆ operator&()

template<typename T>
TRectangle< T > TRectangle< T >::operator& ( const TRectangle< T > &  iOther) const
inline

Compute intersection of this Rect with input Rect and return result Rect.

◆ operator-()

template<typename T>
TRectangle< T > TRectangle< T >::operator- ( const TRectangle< T > &  iOther) const
inline

Compute exclude of this Rect with input Rect and return result Rect.

◆ operator==()

template<typename T>
bool TRectangle< T >::operator== ( const TRectangle< T > &  iOther) const
inline

Strict equality comparison.

◆ operator|()

template<typename T>
TRectangle< T > TRectangle< T >::operator| ( const TRectangle< T > &  iOther) const
inline

Compute union of this Rect with input Rect and return result Rect.

◆ Position()

template<typename T>
TVector2< T > TRectangle< T >::Position ( ) const
inline

Get x and y coordinates as vector.

◆ Sanitize()

template<typename T>
void TRectangle< T >::Sanitize ( )
inline

Sanitize the Rect by setting negative sizes to zero.

◆ Sanitized()

template<typename T>
TRectangle< T > TRectangle< T >::Sanitized ( ) const
inline

Return the sanitized version of this rect.

◆ Shift()

template<typename T>
TRectangle< T >& TRectangle< T >::Shift ( const TVector2< T > &  iVec)
inline

Shift x and y coordinates by input vector.

◆ Size()

template<typename T>
TVector2< T > TRectangle< T >::Size ( ) const
inline

Get the rectuangle size as vector.

◆ TransformAffine()

template<typename T>
void TRectangle< T >::TransformAffine ( const FMat3F iTransform)
inline

Affine transform this rect by input transform ( AABB ).

◆ TransformedAffine()

template<typename T>
TRectangle< T > TRectangle< T >::TransformedAffine ( const FMat3F iTransform) const
inline

Return the affine transformed version of this rect ( AABB ).

◆ TransformedPerspective()

template<typename T>
TRectangle< T > TRectangle< T >::TransformedPerspective ( const FMat3F iTransform) const
inline

Return the perspective transformed version of this rect ( AABB ).

◆ TransformPerspective()

template<typename T>
void TRectangle< T >::TransformPerspective ( const FMat3F iTransform)
inline

Perspective transform this rect by input transform ( AABB ).

◆ UnionLeaveEmpty()

template<typename T>
TRectangle< T > TRectangle< T >::UnionLeaveEmpty ( const TRectangle< T > &  iOther) const
inline

Compute union of this Rect with input Rect and return result Rect, with safeguards for empty rects

Member Data Documentation

◆ Auto

template<typename T>
const TRectangle< T > TRectangle< T >::Auto = TRectangle< T >( 0, 0, std::numeric_limits< T >::max(), std::numeric_limits< T >::max() )
static

◆ h

template<typename T>
T TRectangle< T >::h

The height of the rectangle.

◆ w

template<typename T>
T TRectangle< T >::w

The width of the rectangle.

◆ x

template<typename T>
T TRectangle< T >::x

The x coordinate of the rectangle.

◆ y

template<typename T>
T TRectangle< T >::y

The y coordinate of the rectangle.