Horizon
Loading...
Searching...
No Matches
Public Types | Public Member Functions | List of all members
BOX2< Vec > Class Template Reference

A 2D bounding box built on top of an origin point and size vector. More...

#include <box2.h>

Public Types

typedef Vec::coord_type coord_type
 
typedef Vec::extended_type ecoord_type
 
typedef std::numeric_limits< coord_type > coord_limits
 

Public Member Functions

 BOX2 (const Vec &aPos, const Vec &aSize=Vec(0, 0))
 
void SetMaximum ()
 
Vec Centre () const
 
template<class Container >
void Compute (const Container &aPointList)
 Compute the bounding box from a given list of points.
 
void Move (const Vec &aMoveVector)
 Move the rectangle by the aMoveVector.
 
BOX2< Vec > & Normalize ()
 Ensure that the height ant width are positive.
 
bool Contains (const Vec &aPoint) const
 
bool Contains (coord_type x, coord_type y) const
 
bool Contains (const BOX2< Vec > &aRect) const
 
const Vec & GetSize () const
 
coord_type GetX () const
 
coord_type GetY () const
 
const Vec & GetOrigin () const
 
const Vec & GetPosition () const
 
const Vec GetEnd () const
 
coord_type GetWidth () const
 
coord_type GetHeight () const
 
coord_type GetRight () const
 
coord_type GetBottom () const
 
coord_type GetLeft () const
 
coord_type GetTop () const
 
void MoveTopTo (coord_type aTop)
 
void MoveBottomTo (coord_type aBottom)
 
void MoveLeftTo (coord_type aLeft)
 
void MoveRightTo (coord_type aRight)
 
void SetOrigin (const Vec &pos)
 
void SetOrigin (coord_type x, coord_type y)
 
void SetSize (const Vec &size)
 
void SetSize (coord_type w, coord_type h)
 
void Offset (coord_type dx, coord_type dy)
 
void Offset (const Vec &offset)
 
void SetX (coord_type val)
 
void SetY (coord_type val)
 
void SetWidth (coord_type val)
 
void SetHeight (coord_type val)
 
void SetEnd (coord_type x, coord_type y)
 
void SetEnd (const Vec &pos)
 
bool Intersects (const BOX2< Vec > &aRect) const
 
BOX2< Vec > Intersect (const BOX2< Vec > &aRect)
 Return the intersection of this with another rectangle.
 
const std::string Format () const
 
BOX2< Vec > & Inflate (coord_type dx, coord_type dy)
 Inflates the rectangle horizontally by dx and vertically by dy.
 
BOX2< Vec > & Inflate (int aDelta)
 Inflate the rectangle horizontally and vertically by aDelta.
 
BOX2< Vec > & Merge (const BOX2< Vec > &aRect)
 Modify the position and size of the rectangle in order to contain aRect.
 
BOX2< Vec > & Merge (const Vec &aPoint)
 Modify the position and size of the rectangle in order to contain the given point.
 
ecoord_type GetArea () const
 Return the area of the rectangle.
 
ecoord_type Diagonal () const
 Return the length of the diagonal of the rectangle.
 
ecoord_type SquaredDistance (const Vec &aP) const
 
ecoord_type Distance (const Vec &aP) const
 
ecoord_type SquaredDistance (const BOX2< Vec > &aBox) const
 Return the square of the minimum distance between self and box aBox.
 
ecoord_type Distance (const BOX2< Vec > &aBox) const
 Return the minimum distance between self and aBox.
 
bool operator== (const BOX2< Vec > &aOther) const
 
bool operator!= (const BOX2< Vec > &aOther) const
 

Detailed Description

template<class Vec>
class BOX2< Vec >

A 2D bounding box built on top of an origin point and size vector.

Member Function Documentation

◆ Compute()

template<class Vec >
template<class Container >
void BOX2< Vec >::Compute ( const Container &  aPointList)
inline

Compute the bounding box from a given list of points.

Parameters
aPointListis the list points of the object.

◆ Contains() [1/3]

template<class Vec >
bool BOX2< Vec >::Contains ( const BOX2< Vec > &  aRect) const
inline
Parameters
aRectis the the area to test.
Returns
true if aRect is contained. A common edge is seen as contained.

◆ Contains() [2/3]

template<class Vec >
bool BOX2< Vec >::Contains ( const Vec &  aPoint) const
inline
Parameters
aPointis the point to test.
Returns
true if aPoint is inside the boundary box. A point on a edge is seen as inside.

◆ Contains() [3/3]

template<class Vec >
bool BOX2< Vec >::Contains ( coord_type  x,
coord_type  y 
) const
inline
Parameters
xis the x coordinate of the point to test.
yis the x coordinate of the point to test.
Returns
true if point is inside the boundary box. A point on a edge is seen as inside.

◆ Diagonal()

template<class Vec >
ecoord_type BOX2< Vec >::Diagonal ( ) const
inline

Return the length of the diagonal of the rectangle.

Returns
The length of the rectangle diagonal.

◆ Distance()

template<class Vec >
ecoord_type BOX2< Vec >::Distance ( const BOX2< Vec > &  aBox) const
inline

Return the minimum distance between self and aBox.

Parameters
aBoxis the other box to get the distance from.
Returns
The distance from aBox.

◆ GetArea()

template<class Vec >
ecoord_type BOX2< Vec >::GetArea ( ) const
inline

Return the area of the rectangle.

Returns
The area of the rectangle.

◆ Inflate() [1/2]

template<class Vec >
BOX2< Vec > & BOX2< Vec >::Inflate ( coord_type  dx,
coord_type  dy 
)
inline

Inflates the rectangle horizontally by dx and vertically by dy.

If dx and/or dy is negative the rectangle is deflated.

◆ Inflate() [2/2]

template<class Vec >
BOX2< Vec > & BOX2< Vec >::Inflate ( int  aDelta)
inline

Inflate the rectangle horizontally and vertically by aDelta.

If aDelta is negative the rectangle is deflated.

◆ Intersects()

template<class Vec >
bool BOX2< Vec >::Intersects ( const BOX2< Vec > &  aRect) const
inline
Returns
true if the argument rectangle intersects this rectangle. (i.e. if the 2 rectangles have at least a common point)

◆ Merge() [1/2]

template<class Vec >
BOX2< Vec > & BOX2< Vec >::Merge ( const BOX2< Vec > &  aRect)
inline

Modify the position and size of the rectangle in order to contain aRect.

Parameters
aRectis the rectangle to merge with this rectangle.

◆ Merge() [2/2]

template<class Vec >
BOX2< Vec > & BOX2< Vec >::Merge ( const Vec &  aPoint)
inline

Modify the position and size of the rectangle in order to contain the given point.

Parameters
aPointis the point to merge with the rectangle.

◆ Move()

template<class Vec >
void BOX2< Vec >::Move ( const Vec &  aMoveVector)
inline

Move the rectangle by the aMoveVector.

Parameters
aMoveVectoris a point that is the value to move this rectangle.

◆ SquaredDistance()

template<class Vec >
ecoord_type BOX2< Vec >::SquaredDistance ( const BOX2< Vec > &  aBox) const
inline

Return the square of the minimum distance between self and box aBox.

Parameters
aBoxis the other box.
Returns
The distance squared from aBox.

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