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.

◆ AxisBox() [2/4]

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

Construct a box with opposite corners p1 and p2.

Definition at line 69 of file axisbox.h.

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

◆ 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

◆ boundingBox()

template<int dim = 3>
AxisBox WFMath::AxisBox< dim >::boundingBox ( ) const
inline

Definition at line 133 of file axisbox.h.

◆ boundingSphere()

template<int dim>
Ball< dim > WFMath::AxisBox< dim >::boundingSphere
inline

Definition at line 117 of file axisbox_funcs.h.

◆ boundingSphereSloppy()

template<int dim>
Ball< dim > WFMath::AxisBox< dim >::boundingSphereSloppy
inline

Definition at line 123 of file axisbox_funcs.h.

◆ 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.

◆ getCenter()

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

Definition at line 97 of file axisbox.h.

◆ getCorner()

template<int dim>
Point< dim > WFMath::AxisBox< dim >::getCorner ( size_t  i) const

Definition at line 99 of file axisbox_funcs.h.

◆ highCorner() [1/2]

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

Definition at line 104 of file axisbox.h.

◆ highCorner() [2/2]

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.

◆ isEqualTo()

template<int dim>
bool WFMath::AxisBox< dim >::isEqualTo ( const AxisBox< dim > &  b,
CoordType  epsilon = numeric_constants<CoordType>::epsilon() 
) const
inline

Definition at line 183 of file axisbox.h.

◆ isValid()

template<int dim = 3>
bool WFMath::AxisBox< dim >::isValid ( ) const
inline

Definition at line 91 of file axisbox.h.

◆ lowCorner() [1/2]

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

Definition at line 101 of file axisbox.h.

◆ lowCorner() [2/2]

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.

◆ 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.

◆ moveCenterTo()

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

Definition at line 126 of file axisbox.h.

◆ moveCornerTo()

template<int dim = 3>
AxisBox & WFMath::AxisBox< dim >::moveCornerTo ( const Point< dim > &  p,
size_t  corner 
)
inline

Definition at line 124 of file axisbox.h.

◆ numCorners()

template<int dim = 3>
size_t WFMath::AxisBox< dim >::numCorners ( ) const
inline

Definition at line 95 of file axisbox.h.

◆ operator!=()

template<int dim = 3>
bool WFMath::AxisBox< dim >::operator!= ( const AxisBox< dim > &  a) const
inline

Definition at line 89 of file axisbox.h.

◆ operator==()

template<int dim = 3>
bool WFMath::AxisBox< dim >::operator== ( const AxisBox< dim > &  a) const
inline

Definition at line 88 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().

◆ shift()

template<int dim = 3>
AxisBox & WFMath::AxisBox< dim >::shift ( const Vector< dim > &  v)
inline

Definition at line 122 of file axisbox.h.

◆ toAtlas()

template<int dim>
AtlasOutType WFMath::AxisBox< dim >::toAtlas
inline

Create an Atlas object from the box.

Definition at line 257 of file atlasconv.h.

References WFMath::AxisBox< dim >::toAtlas().

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

◆ toLocalCoords() [1/2]

template<int dim = 3>
AxisBox WFMath::AxisBox< dim >::toLocalCoords ( const AxisBox< dim > &  coords) const
inline

Definition at line 148 of file axisbox.h.

◆ toLocalCoords() [2/2]

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

Definition at line 146 of file axisbox.h.

◆ toParentCoords() [1/2]

template<int dim = 3>
AxisBox WFMath::AxisBox< dim >::toParentCoords ( const AxisBox< dim > &  coords) const
inline

Definition at line 139 of file axisbox.h.

◆ toParentCoords() [2/2]

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

Definition at line 137 of file axisbox.h.

◆ 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.

Friends And Related Function Documentation

◆ Contains [1/9]

template<int dim = 3>
bool Contains ( const AxisBox< dim > &  a,
const Ball< dim > &  b,
bool  proper 
)
friend

Definition at line 159 of file intersect.h.

◆ Contains [2/9]

template<int dim = 3>
bool Contains ( const AxisBox< dim > &  b,
const Polygon< dim > &  p,
bool  proper 
)
friend

Definition at line 461 of file polygon_intersect.cpp.

◆ Contains [3/9]

template<int dim = 3>
bool Contains ( const AxisBox< dim > &  b,
const RotBox< dim > &  r,
bool  proper 
)
friend

Definition at line 416 of file intersect.h.

◆ Contains [4/9]

template<int dim = 3>
bool Contains ( const AxisBox< dim > &  outer,
const AxisBox< dim > &  inner,
bool  proper 
)
friend

Definition at line 100 of file intersect.h.

◆ Contains [5/9]

template<int dim = 3>
bool Contains ( const Ball< dim > &  b,
const AxisBox< dim > &  a,
bool  proper 
)
friend

Definition at line 145 of file intersect.h.

◆ Contains [6/9]

template<int dim = 3>
bool Contains ( const Point< dim > &  p,
const AxisBox< dim > &  b,
bool  proper 
)
friend

Definition at line 83 of file intersect.h.

◆ Contains [7/9]

template<int dim = 3>
bool Contains ( const Polygon< dim > &  p,
const AxisBox< dim > &  b,
bool  proper 
)
friend

Definition at line 455 of file polygon_intersect.cpp.

◆ Contains [8/9]

template<int dim = 3>
bool Contains ( const RotBox< dim > &  r,
const AxisBox< dim > &  b,
bool  proper 
)
friend

Definition at line 406 of file intersect.h.

◆ Contains [9/9]

template<int dim = 3>
bool Contains ( const Segment< dim > &  s,
const AxisBox< dim > &  b,
bool  proper 
)
friend

Definition at line 254 of file intersect.h.

◆ Intersect [1/5]

template<int dim = 3>
bool Intersect ( const AxisBox< dim > &  b,
const Point< dim > &  p,
bool  proper 
)
friend

Definition at line 73 of file intersect.h.

◆ Intersect [2/5]

template<int dim = 3>
bool Intersect ( const AxisBox< dim > &  b1,
const AxisBox< dim > &  b2,
bool  proper 
)
friend

Definition at line 89 of file intersect.h.

◆ Intersect [3/5]

template<int dim = 3>
bool Intersect ( const Ball< dim > &  b,
const AxisBox< dim > &  a,
bool  proper 
)
friend

Definition at line 126 of file intersect.h.

◆ Intersect [4/5]

template<int dim = 3>
bool Intersect ( const Polygon< dim > &  p,
const AxisBox< dim > &  b,
bool  proper 
)
friend

Definition at line 371 of file polygon_intersect.cpp.

◆ Intersect [5/5]

template<int dim = 3>
bool Intersect ( const Segment< dim > &  s,
const AxisBox< dim > &  b,
bool  proper 
)
friend

Definition at line 216 of file intersect.h.

◆ 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.

◆ operator>>

template<int dim = 3>
std::istream & operator>> ( std::istream &  is,
AxisBox< dim > &  a 
)
friend

Definition at line 194 of file stream.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: