wfmath  1.0.3
A math library for the Worldforge system.
WFMath::AxisBox< dim > Class Template Reference

A dim dimensional axis-aligned box. More...

#include <axisbox.h>

Public Member Functions

 AxisBox ()=default
 Construct an uninitialized box. More...
 
 AxisBox (const Point< dim > &p1, const Point< dim > &p2, bool ordered=false)
 Construct a box with opposite corners p1 and p2. More...
 
 AxisBox (const AxisBox &a)=default
 Construct a copy of a box. More...
 
 AxisBox (const AtlasInType &a)
 Construct a box from an object passed by Atlas. More...
 
AtlasOutType toAtlas () const
 Create an Atlas object from the box. More...
 
void fromAtlas (const AtlasInType &a)
 Set the box's value to that given by an Atlas object. More...
 
AxisBoxoperator= (const AxisBox &a)=default
 
bool isEqualTo (const AxisBox &b, CoordType epsilon=numeric_constants< CoordType >::epsilon()) const
 
bool operator== (const AxisBox &a) const
 
bool operator!= (const AxisBox &a) const
 
bool isValid () const
 
size_t numCorners () const
 
Point< dim > getCorner (size_t i) const
 
Point< dim > getCenter () const
 
const Point< dim > & lowCorner () const
 Get a reference to corner 0. More...
 
Point< dim > & lowCorner ()
 
const Point< dim > & highCorner () const
 Get a reference to corner (2^dim)-1. More...
 
Point< dim > & highCorner ()
 
CoordType lowerBound (const int axis) const
 Get the lower bound of the box on the i'th axis. More...
 
CoordType upperBound (const int axis) const
 Get the upper bound of the box on the i'th axis. More...
 
AxisBoxsetCorners (const Point< dim > &p1, const Point< dim > &p2, bool ordered=false)
 Set the box to have opposite corners p1 and p2. More...
 
AxisBoxshift (const Vector< dim > &v)
 
AxisBoxmoveCornerTo (const Point< dim > &p, size_t corner)
 
AxisBoxmoveCenterTo (const Point< dim > &p)
 
AxisBox boundingBox () const
 
Ball< dim > boundingSphere () const
 
Ball< dim > boundingSphereSloppy () const
 
AxisBox toParentCoords (const Point< dim > &origin) const
 
AxisBox toParentCoords (const AxisBox< dim > &coords) const
 
AxisBox toLocalCoords (const Point< dim > &origin) const
 
AxisBox toLocalCoords (const AxisBox< dim > &coords) const
 

Friends

std::ostream & operator (std::ostream &os, const AxisBox &a)
 
std::istream & operator>> (std::istream &is, AxisBox &a)
 
bool Intersection (const AxisBox &a1, const AxisBox &a2, AxisBox &out)
 Return true if the boxes intersect, and set 'out' to their intersection. More...
 
AxisBox Union (const AxisBox &a1, const AxisBox &a2)
 Get the minimal box that contains a1 and a2. More...
 
bool Intersect (const AxisBox &b, const Point< dim > &p, bool proper)
 
bool Contains (const Point< dim > &p, const AxisBox &b, bool proper)
 
bool Intersect (const AxisBox &b1, const AxisBox &b2, bool proper)
 
bool Contains (const AxisBox &outer, const AxisBox &inner, bool proper)
 
bool Intersect (const Ball< dim > &b, const AxisBox &a, bool proper)
 
bool Contains (const Ball< dim > &b, const AxisBox &a, bool proper)
 
bool Contains (const AxisBox &a, const Ball< dim > &b, bool proper)
 
bool Intersect (const Segment< dim > &s, const AxisBox &b, bool proper)
 
bool Contains (const Segment< dim > &s, const AxisBox &b, bool proper)
 
bool Intersect (const RotBox< dim > &r, const AxisBox &b, bool proper)
 
bool Contains (const RotBox< dim > &r, const AxisBox &b, bool proper)
 
bool Contains (const AxisBox &b, const RotBox< dim > &r, bool proper)
 
bool Intersect (const Polygon< dim > &p, const AxisBox &b, bool proper)
 
bool Contains (const Polygon< dim > &p, const AxisBox &b, bool proper)
 
bool Contains (const AxisBox &b, const Polygon< dim > &p, bool proper)
 

Detailed Description

template<int dim = 3>
class WFMath::AxisBox< dim >

A dim dimensional axis-aligned box.

This class implements the full shape interface, as described in the fake class Shape, with the exception of the rotation functions.

Definition at line 63 of file axisbox.h.

Constructor & Destructor Documentation

◆ AxisBox() [1/4]

template<int dim = 3>
WFMath::AxisBox< dim >::AxisBox ( )
default

Construct an uninitialized box.

Referenced by WFMath::AxisBox< dim >::AxisBox(), and WFMath::AxisBox< dim >::upperBound().

◆ AxisBox() [2/4]

template<int dim = 3>
WFMath::AxisBox< dim >::AxisBox ( const Point< dim > &  p1,
const Point< dim > &  p2,
bool  ordered = false 
)
inline

◆ AxisBox() [3/4]

template<int dim = 3>
WFMath::AxisBox< dim >::AxisBox ( const AxisBox< dim > &  a)
default

Construct a copy of a box.

◆ AxisBox() [4/4]

template<int dim>
WFMath::AxisBox< dim >::AxisBox ( const AtlasInType a)
inlineexplicit

Construct a box from an object passed by Atlas.

Definition at line 209 of file atlasconv.h.

Member Function Documentation

◆ fromAtlas()

template<int dim>
void WFMath::AxisBox< dim >::fromAtlas ( const AtlasInType a)
inline

Set the box's value to that given by an Atlas object.

Definition at line 215 of file atlasconv.h.

Referenced by WFMath::AxisBox< dim >::AxisBox().

◆ highCorner()

template<int dim = 3>
const Point<dim>& WFMath::AxisBox< dim >::highCorner ( ) const
inline

Get a reference to corner (2^dim)-1.

Definition at line 103 of file axisbox.h.

◆ lowCorner()

template<int dim = 3>
const Point<dim>& WFMath::AxisBox< dim >::lowCorner ( ) const
inline

Get a reference to corner 0.

Definition at line 100 of file axisbox.h.

Referenced by WFMath::BoundingBox().

◆ lowerBound()

template<int dim = 3>
CoordType WFMath::AxisBox< dim >::lowerBound ( const int  axis) const
inline

Get the lower bound of the box on the i'th axis.

Definition at line 107 of file axisbox.h.

◆ setCorners()

template<int dim>
AxisBox< dim > & WFMath::AxisBox< dim >::setCorners ( const Point< dim > &  p1,
const Point< dim > &  p2,
bool  ordered = false 
)

Set the box to have opposite corners p1 and p2.

The 'ordered' variable may be set to true if p1[i] <= p2[i] for all i. It is always safe to leave 'ordered' as false, it is a speed optimization primarily intended for use inside the library.

Definition at line 72 of file axisbox_funcs.h.

References WFMath::Point< dim >::setValid().

Referenced by WFMath::AxisBox< dim >::AxisBox(), and WFMath::AxisBox< dim >::upperBound().

◆ toAtlas()

template<int dim>
AtlasOutType WFMath::AxisBox< dim >::toAtlas ( ) const
inline

Create an Atlas object from the box.

Definition at line 257 of file atlasconv.h.

Referenced by WFMath::AxisBox< dim >::AxisBox().

◆ upperBound()

template<int dim = 3>
CoordType WFMath::AxisBox< dim >::upperBound ( const int  axis) const
inline

Get the upper bound of the box on the i'th axis.

Definition at line 109 of file axisbox.h.

References WFMath::AxisBox< dim >::AxisBox(), and WFMath::AxisBox< dim >::setCorners().

Friends And Related Function Documentation

◆ Intersection

template<int dim = 3>
bool Intersection ( const AxisBox< dim > &  a1,
const AxisBox< dim > &  a2,
AxisBox< dim > &  out 
)
friend

Return true if the boxes intersect, and set 'out' to their intersection.

Definition at line 40 of file axisbox_funcs.h.

◆ Union

template<int dim = 3>
AxisBox Union ( const AxisBox< dim > &  a1,
const AxisBox< dim > &  a2 
)
friend

Get the minimal box that contains a1 and a2.

Definition at line 56 of file axisbox_funcs.h.


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