Horizon
Public Types | Public Member Functions | List of all members
BOX2< Vec > Class Template Reference

Class BOX2 handles a 2-D bounding box, built on top of an origin point and size vector, both of templated class Vec. 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)
 
void SetMaximum ()
 
Vec Centre () const
 
template<class Container >
void Compute (const Container &aPointList)
 Compute the bounding box from a given list of points. More...
 
void Move (const Vec &aMoveVector)
 Function Move moves the rectangle by the aMoveVector. More...
 
BOX2< Vec > & Normalize ()
 Function Normalize ensures that the height ant width are positive.
 
bool Contains (const Vec &aPoint) const
 Function Contains. More...
 
bool Contains (coord_type x, coord_type y) const
 Function Contains. More...
 
bool Contains (const BOX2< Vec > &aRect) const
 Function Contains. More...
 
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
 Function Intersects. More...
 
BOX2< Vec > Intersect (const BOX2< Vec > &aRect)
 Function Intersect Returns the intersection of this with another rectangle.
 
const std::string Format () const
 
BOX2< Vec > & Inflate (coord_type dx, coord_type dy)
 Function Inflate inflates the rectangle horizontally by dx and vertically by dy. More...
 
BOX2< Vec > & Inflate (int aDelta)
 Function Inflate inflates the rectangle horizontally and vertically by aDelta. More...
 
BOX2< Vec > & Merge (const BOX2< Vec > &aRect)
 Function Merge modifies the position and size of the rectangle in order to contain aRect. More...
 
BOX2< Vec > & Merge (const Vec &aPoint)
 Function Merge modifies the position and size of the rectangle in order to contain the given point. More...
 
ecoord_type GetArea () const
 Function GetArea returns the area of the rectangle. More...
 
ecoord_type Diagonal () const
 Function GetArea returns the length of the diagonal of the rectangle. More...
 
ecoord_type SquaredDistance (const Vec &aP) const
 
ecoord_type Distance (const Vec &aP) const
 
ecoord_type SquaredDistance (const BOX2< Vec > &aBox) const
 Function SquaredDistance returns the square of the minimum distance between self and box aBox. More...
 
ecoord_type Distance (const BOX2< Vec > &aBox) const
 Function Distance returns the minimum distance between self and box aBox. More...
 

Detailed Description

template<class Vec>
class BOX2< Vec >

Class BOX2 handles a 2-D bounding box, built on top of an origin point and size vector, both of templated class Vec.

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

Function Contains.

Parameters
aRect= the BOX2 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

Function Contains.

Parameters
aPoint= 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

Function Contains.

Parameters
x= the x coordinate of the point to test
y= 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

Function GetArea returns the length of the diagonal of the rectangle.

Returns
The area of the diagonal.

◆ Distance()

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

Function Distance returns the minimum distance between self and box aBox.

Parameters
aBoxthe other box
Returns
The distance

◆ GetArea()

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

Function GetArea returns 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

Function Inflate 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

Function Inflate inflates 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

Function Intersects.

Returns
bool - 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

Function Merge modifies the position and size of the rectangle in order to contain aRect.

It is mainly used to calculate bounding boxes.

Parameters
aRectThe rectangle to merge with this rectangle.

◆ Merge() [2/2]

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

Function Merge modifies the position and size of the rectangle in order to contain the given point.

Parameters
aPointThe point to merge with the rectangle.

◆ Move()

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

Function Move moves the rectangle by the aMoveVector.

Parameters
aMoveVectorA point that is the value to move this rectangle

◆ SquaredDistance()

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

Function SquaredDistance returns the square of the minimum distance between self and box aBox.

Parameters
aBoxthe other box
Returns
The distance, squared

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