JugiMap Framework
Rect< T > Struct Template Reference

Rectangle. More...

#include <jmCommon.h>

Public Member Functions

 Rect ()
 Constructs an empty 'null' rectangle. More...
 
 Rect (T xMin, T yMin, T xMax, T yMax)
 Constructs a rectangle from the given minimum and maximum coordinates. More...
 
 Rect (const Vec2< T > &_min, const Vec2< T > &_max)
 Constructs a rectangle from the given minimum and maximum vectors . More...
 
bool operator== (const Rect< T > &r) const
 Returns true if this rectangle is equal to the given rectangle r; otherwise returns false. More...
 
bool operator!= (const Rect< T > &r) const
 Returns true if this rectangle is not equal to the given rectangle r; otherwise returns false. More...
 
bool Equals (const Rect< T > &r, float epsilon=0.00001f) const
 
T GetWidth () const
 Returns the width of this rectangle. More...
 
T GetHeight () const
 Returns the height of this rectangle. More...
 
Rect< TUnite (const Rect< T > &r) const
 Returns a rectangle formed by uniting this rectangle with the given rectangle r. More...
 
Rect< TExpand (const Vec2< T > &v) const
 Returns a rectangle formed by expanding this rectangle by the given vector v. More...
 
Vec2< TGetSize () const
 Returns a vector storing the size of this rectangle; the width is stored in x and the height is stored in y More...
 
Vec2< TGetCenter () const
 Returns a vector storing the center point of this rectangle. More...
 
bool IsEmpty ()
 Returns true if the minimum and maximum coordinates are equal; otherwise returns false. More...
 
bool IsValid ()
 Returns true if the maximum coordinate is bigger or equal to the minimum coordinate; otherwise returns false. More...
 
bool Contains (const Vec2< T > &v) const
 Returns true if the given vector point v is inside this rectangle; otherwise returns false. More...
 
bool Contains (const Rect< T > &r) const
 Returns true if the given rectangle r is inside this rectangle; otherwise returns false. More...
 
bool Intersects (const Rect< T > &r) const
 Returns true if the given rectangle r is intersects this rectangle; otherwise returns false. More...
 

Public Attributes

Vec2< Tmin
 The minimum coordinate (the left-top corner when y coordinate points downward). More...
 
Vec2< Tmax
 The maximum coordinate (the right-bottom corner when y coordinate points downward). More...
 

Detailed Description

template<typename T>
struct jugimap::Rect< T >

Rectangle.

Constructor & Destructor Documentation

◆ Rect() [1/3]

Rect ( )
inline

Constructs an empty 'null' rectangle.

◆ Rect() [2/3]

Rect ( T  xMin,
T  yMin,
T  xMax,
T  yMax 
)
inline

Constructs a rectangle from the given minimum and maximum coordinates.

◆ Rect() [3/3]

Rect ( const Vec2< T > &  _min,
const Vec2< T > &  _max 
)
inline

Constructs a rectangle from the given minimum and maximum vectors .

Member Function Documentation

◆ operator==()

bool operator== ( const Rect< T > &  r) const
inline

Returns true if this rectangle is equal to the given rectangle r; otherwise returns false.

◆ operator!=()

bool operator!= ( const Rect< T > &  r) const
inline

Returns true if this rectangle is not equal to the given rectangle r; otherwise returns false.

◆ Equals()

bool Equals ( const Rect< T > &  r,
float  epsilon = 0.00001f 
) const
inline

Returns true if this rectangle is equal to the given rectangle r; otherwise returns false. For floating-point types: two compared numbers are considered equal if their difference is smaller then the given epsilon.

◆ GetWidth()

T GetWidth ( ) const
inline

Returns the width of this rectangle.

◆ GetHeight()

T GetHeight ( ) const
inline

Returns the height of this rectangle.

◆ Unite()

Rect<T> Unite ( const Rect< T > &  r) const
inline

Returns a rectangle formed by uniting this rectangle with the given rectangle r.

◆ Expand()

Rect<T> Expand ( const Vec2< T > &  v) const
inline

Returns a rectangle formed by expanding this rectangle by the given vector v.

◆ GetSize()

Vec2<T> GetSize ( ) const
inline

Returns a vector storing the size of this rectangle; the width is stored in x and the height is stored in y

◆ GetCenter()

Vec2<T> GetCenter ( ) const
inline

Returns a vector storing the center point of this rectangle.

◆ IsEmpty()

bool IsEmpty ( )
inline

Returns true if the minimum and maximum coordinates are equal; otherwise returns false.

◆ IsValid()

bool IsValid ( )
inline

Returns true if the maximum coordinate is bigger or equal to the minimum coordinate; otherwise returns false.

◆ Contains() [1/2]

bool Contains ( const Vec2< T > &  v) const
inline

Returns true if the given vector point v is inside this rectangle; otherwise returns false.

◆ Contains() [2/2]

bool Contains ( const Rect< T > &  r) const
inline

Returns true if the given rectangle r is inside this rectangle; otherwise returns false.

◆ Intersects()

bool Intersects ( const Rect< T > &  r) const
inline

Returns true if the given rectangle r is intersects this rectangle; otherwise returns false.

Member Data Documentation

◆ min

Vec2<T> min

The minimum coordinate (the left-top corner when y coordinate points downward).

◆ max

Vec2<T> max

The maximum coordinate (the right-bottom corner when y coordinate points downward).


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