Kaim::Box2LL Class Reference

Kaim::Box2LL Class Reference

#include <box2ll.h>

Class Description

Each instance of this class also maintains a count of the number of elements (or grid cells) contained by the box along its X and Y axes, accessible through the CountX() and CountY() methods.

For coordinate boxes, all coordinates along the edge of the box are counted, including the corners. For grid boxes, all grid cells that are contained within the box are counted.

Constructors

 Box2LL ()
 
 Box2LL (const Vec2LL &min_, const Vec2LL &max_)
 
 Box2LL (KyInt64 min_x, KyInt64 min_y, KyInt64 max_x, KyInt64 max_y)
 

Main API Functions

bool IsValid ()
 
void MakeZero ()
 
void Set (const Vec2LL &min_, const Vec2LL &max_)
 
void SetMin (const Vec2LL &min_)
 
void SetMax (const Vec2LL &max_)
 
const Vec2LLMin () const
 
const Vec2LLMax () const
 
Vec2LL CornerSouthWest () const
 
Vec2LL CornerNorthEast () const
 
Vec2LL CornerSouthEast () const
 
Vec2LL CornerNorthWest () const
 
bool IsInside (const Vec2LL &pos) const
 
bool IsInsideStrictly (const Vec2LL &pos) const
 
void Clear ()
 
Box2LLoperator*= (KyInt64 s)
 
Box2LLoperator/= (KyInt64 s)
 
Box2LLoperator+= (const Vec2LL &v)
 
Box2LLoperator-= (const Vec2LL &v)
 
bool operator== (const Box2LL &other) const
 
void ExpandByVec2 (const Vec2LL &pos)
 
void ExpandByBox2 (const Box2LL &box)
 
void Enlarge (KyInt64 enlargement)
 
void GetEnlarged (KyInt64 enlargement, Box2LL &enlarged) const
 
bool IntersectWith (const Box2LL &box)
 
bool SetAsIntersection (const Box2LL &box_1, const Box2LL &box_2)
 

Constructor & Destructor Documentation

Kaim::Box2LL::Box2LL ( )
inline

Creates a new Box2LL with invalid extents: you must call Set() before using it.

Kaim::Box2LL::Box2LL ( const Vec2LL min_,
const Vec2LL max_ 
)
inline

Creates a new Box2LL with the provided extents.

Parameters
min_The minima of the bounding box.
max_The maxima of the bounding box.
Kaim::Box2LL::Box2LL ( KyInt64  min_x,
KyInt64  min_y,
KyInt64  max_x,
KyInt64  max_y 
)
inline

Creates a new Box2LL with the provided extents.

Parameters
min_xThe minimum position of the bounding box on the X axis.
min_yThe minimum position of the bounding box on the Y axis.
max_xThe maximum position of the bounding box on the X axis.
max_yThe maximum position of the bounding box on the Y axis.

Member Function Documentation

void Kaim::Box2LL::Clear ( )
inline

Clears all information maintained by this object.

This method sets the extents of the box to invalid values; you must follow this method with a call to Set() before you can use the box.

Vec2LL Kaim::Box2LL::CornerNorthEast ( ) const
inline

Retrieves the coordinates of the North-East corner of the bounding box.

Since North is considered to be the positive direction of the Y axis and East is considered to be the positive direction of the Y axis, this corner is equivalent to the maxima.

Vec2LL Kaim::Box2LL::CornerNorthWest ( ) const
inline

Retrieves the coordinates of the North-West corner of the bounding box.

Since North is considered to be the positive direction of the Y axis and East is considered to be the positive direction of the Y axis, this corner has the maximum value on the Y axis and the minimum value on the X axis.

Vec2LL Kaim::Box2LL::CornerSouthEast ( ) const
inline

Retrieves the coordinates of the South-East corner of the bounding box.

Since North is considered to be the positive direction of the Y axis and East is considered to be the positive direction of the Y axis, this corner has the minimum value on the Y axis and the maximum value on the X axis.

Vec2LL Kaim::Box2LL::CornerSouthWest ( ) const
inline

Retrieves the coordinates of the South-West corner of the bounding box.

Since North is considered to be the positive direction of the Y axis and East is considered to be the positive direction of the Y axis, this corner is equivalent to the minima.

void Kaim::Box2LL::Enlarge ( KyInt64  enlargement)
inline

Enlarges the extents of the bounding box by the specified amount in all directions.

void Kaim::Box2LL::ExpandByBox2 ( const Box2LL box)
inline

Enlarges the extents of the bounding box to include the area covered by the specified bounding box.

If the bounding box already encompasses the area of box, the bounding box is not modified.

void Kaim::Box2LL::ExpandByVec2 ( const Vec2LL pos)
inline

Enlarges the extents of the bounding box to include the specified two-dimensional point.

If the point is already contained within the bounding box, the box is not modified.

void Kaim::Box2LL::GetEnlarged ( KyInt64  enlargement,
Box2LL enlarged 
) const
inline

Enlarges the extents of the bounding box by the specified amount in all directions, and stores the new dimensions in the enlarged parameter.

Parameters
enlargementThe amount to enlarge the box in each direction.
[out]enlargedStores the enlarged bounding box.
bool Kaim::Box2LL::IntersectWith ( const Box2LL box)
inline

Resizes this bounding box to contain only the grid cells that are common to both it and box.

This has the following results:

  • If box is entirely contained within this bounding box, this bounding box is resized to match the extents of box.
  • If the edges of this bounding box cross the edges of box, the extents of this bounding box are resized to include only the area common to both bounding boxes.
  • If this bounding box is entirely contained within the extents of box, this bounding box is not altered.
  • If this bounding box does not intersect box at all, the extents of this bounding box are set to invalid values and this method returns false.
    Returns
    true if the boxes intersect, or false if they do not. If this method returns false, the extents of this bounding box will be set to invalid values. You must call Set() before you can use the box again.
bool Kaim::Box2LL::IsInside ( const Vec2LL pos) const
inline

Returns true if the specified position is contained within the extents of the bounding box or if the specified position is located on the edge of the bounding box.

bool Kaim::Box2LL::IsInsideStrictly ( const Vec2LL pos) const
inline

Returns true if the specified position is contained entirely within the extents of the bounding box.

bool Kaim::Box2LL::IsValid ( )
inline

Indicates whether or not the extents of the bounding box are valid.

void Kaim::Box2LL::MakeZero ( )
inline

Sets both the minima and maxima of the bounding box to (0,0).

const Vec2LL& Kaim::Box2LL::Max ( ) const
inline

Retrieves the maxima of the bounding box.

const Vec2LL& Kaim::Box2LL::Min ( ) const
inline

Retrieves the minima of the bounding box.

Box2LL& Kaim::Box2LL::operator*= ( KyInt64  s)
inline

Multiplies both the minima and maxima of the box by the specified value.

Box2LL& Kaim::Box2LL::operator+= ( const Vec2LL v)
inline

Adds the specified two-dimensional vector to both the minima and maxima of the box.

Box2LL& Kaim::Box2LL::operator-= ( const Vec2LL v)
inline

Subtracts the specified two-dimensional vector from both the minima and maxima of the box.

Box2LL& Kaim::Box2LL::operator/= ( KyInt64  s)
inline

Divides both the minima and maxima of the box by the specified value.

bool Kaim::Box2LL::operator== ( const Box2LL other) const
inline

Check equality.

void Kaim::Box2LL::Set ( const Vec2LL min_,
const Vec2LL max_ 
)
inline

Sets the extents of the bounding box to the specified values.

Parameters
min_The minima of the bounding box.
max_The maxima of the bounding box.
bool Kaim::Box2LL::SetAsIntersection ( const Box2LL box_1,
const Box2LL box_2 
)
inline

Resizes this bounding box to contain only the grid cells that are common to both box_1 and box_2.

This has the following results:

  • If one box is entirely contained within the other, this bounding box is set to match the extents of the smaller box.
  • If the edges of the two boxes cross, the extents of this bounding box are resized to include only the area common to both box_1 and box_2.
  • Ifbox_1 and box_2 do not intersect at all, the extents of this bounding box are set to invalid values and this method returns false.
    Returns
    true ifbox_1 and box_2 intersect, or false if they do not. If this method returns false, the extents of this bounding box will be set to invalid values. You must call Set() before you can use the box again.
void Kaim::Box2LL::SetMax ( const Vec2LL max_)
inline

Sets the maxima of the bounding box to the specified coordinates.

void Kaim::Box2LL::SetMin ( const Vec2LL min_)
inline

Sets the minima of the bounding box to the specified coordinates.


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