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

A dim dimensional ball. More...

#include <ball.h>

Public Member Functions

 Ball ()
 construct an uninitialized ball More...
 
 Ball (const Point< dim > &center, CoordType radius)
 construct a ball with the given center and radius More...
 
 Ball (const Ball &b)=default
 construct a copy of a ball More...
 
 Ball (const AtlasInType &a)
 Construct a ball 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...
 
Balloperator= (const Ball &b)=default
 
bool isEqualTo (const Ball &b, CoordType epsilon=numeric_constants< CoordType >::epsilon()) const
 
bool operator== (const Ball &b) const
 
bool operator!= (const Ball &b) const
 
bool isValid () const
 
size_t numCorners () const
 
Point< dim > getCorner (size_t) const
 
Point< dim > getCenter () const
 
const Point< dim > & center () const
 get the center of the ball More...
 
Point< dim > & center ()
 get the center of the ball More...
 
CoordType radius () const
 get the radius of the ball More...
 
CoordTyperadius ()
 get the radius of the ball More...
 
Ballshift (const Vector< dim > &v)
 
BallmoveCornerTo (const Point< dim > &, size_t)
 
BallmoveCenterTo (const Point< dim > &p)
 
BallrotateCorner (const RotMatrix< dim > &, size_t)
 
BallrotateCenter (const RotMatrix< dim > &)
 
BallrotatePoint (const RotMatrix< dim > &m, const Point< dim > &p)
 
BallrotateCorner (const Quaternion &, size_t corner)
 
BallrotateCenter (const Quaternion &)
 
BallrotatePoint (const Quaternion &q, const Point< dim > &p)
 
AxisBox< dim > boundingBox () const
 
Ball boundingSphere () const
 
Ball boundingSphereSloppy () const
 
Ball toParentCoords (const Point< dim > &origin, const RotMatrix< dim > &rotation=RotMatrix< dim >().identity()) const
 
Ball toParentCoords (const AxisBox< dim > &coords) const
 
Ball toParentCoords (const RotBox< dim > &coords) const
 
Ball toLocalCoords (const Point< dim > &origin, const RotMatrix< dim > &rotation=RotMatrix< dim >().identity()) const
 
Ball toLocalCoords (const AxisBox< dim > &coords) const
 
Ball toLocalCoords (const RotBox< dim > &coords) const
 
Ball toParentCoords (const Point< dim > &origin, const Quaternion &rotation) const
 
Ball toLocalCoords (const Point< dim > &origin, const Quaternion &rotation) const
 
Ball< 3 > & rotateCorner (const Quaternion &, size_t)
 
Ball< 3 > & rotateCenter (const Quaternion &)
 
Ball< 3 > & rotatePoint (const Quaternion &q, const Point< 3 > &p)
 
Ball< 3 > toParentCoords (const Point< 3 > &origin, const Quaternion &rotation) const
 
Ball< 3 > toLocalCoords (const Point< 3 > &origin, const Quaternion &rotation) const
 

Friends

std::ostream & operator (std::ostream &os, const Ball &b)
 
std::istream & operator>> (std::istream &is, Ball &b)
 
bool Intersect (const Ball &b, const Point< dim > &p, bool proper)
 
bool Contains (const Point< dim > &p, const Ball &b, bool proper)
 
bool Intersect (const Ball &b, const AxisBox< dim > &a, bool proper)
 
bool Contains (const Ball &b, const AxisBox< dim > &a, bool proper)
 
bool Contains (const AxisBox< dim > &a, const Ball &b, bool proper)
 
bool Intersect (const Ball &b1, const Ball &b2, bool proper)
 
bool Contains (const Ball &outer, const Ball &inner, bool proper)
 
bool Intersect (const Segment< dim > &s, const Ball &b, bool proper)
 
bool Contains (const Segment< dim > &s, const Ball &b, bool proper)
 
bool Intersect (const RotBox< dim > &r, const Ball &b, bool proper)
 
bool Contains (const RotBox< dim > &r, const Ball &b, bool proper)
 
bool Contains (const Ball &b, const RotBox< dim > &r, bool proper)
 
bool Intersect (const Polygon< dim > &p, const Ball &b, bool proper)
 
bool Contains (const Polygon< dim > &p, const Ball &b, bool proper)
 
bool Contains (const Ball &b, const Polygon< dim > &p, bool proper)
 

Detailed Description

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

A dim dimensional ball.

This class implements the full shape interface, as described in the fake class Shape.

This class is called Ball<> instead of Sphere to be more in tune with the usual mathematical naming conventions, where a ball is a filled object, while a sphere is just the outer shell. It also helps that a Ball<n> corresponds to an n-ball, while a Sphere<n> would correspond to an (n-1)-sphere.

Definition at line 60 of file ball.h.

Constructor & Destructor Documentation

◆ Ball() [1/4]

template<int dim = 3>
WFMath::Ball< dim >::Ball ( )
inline

construct an uninitialized ball

Definition at line 64 of file ball.h.

◆ Ball() [2/4]

template<int dim = 3>
WFMath::Ball< dim >::Ball ( const Point< dim > &  center,
CoordType  radius 
)
inline

construct a ball with the given center and radius

Definition at line 66 of file ball.h.

References WFMath::Ball< dim >::radius(), and WFMath::Point< dim >::setValid().

◆ Ball() [3/4]

template<int dim = 3>
WFMath::Ball< dim >::Ball ( const Ball< dim > &  b)
default

construct a copy of a ball

◆ Ball() [4/4]

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

Construct a ball from an object passed by Atlas.

Definition at line 318 of file atlasconv.h.

References WFMath::Ball< dim >::fromAtlas().

Member Function Documentation

◆ boundingBox()

template<int dim>
AxisBox< dim > WFMath::Ball< dim >::boundingBox

Definition at line 39 of file ball_funcs.h.

◆ boundingSphere()

template<int dim = 3>
Ball WFMath::Ball< dim >::boundingSphere ( ) const
inline

Definition at line 130 of file ball.h.

◆ boundingSphereSloppy()

template<int dim = 3>
Ball WFMath::Ball< dim >::boundingSphereSloppy ( ) const
inline

Definition at line 131 of file ball.h.

◆ center() [1/2]

template<int dim = 3>
Point< dim > & WFMath::Ball< dim >::center ( )
inline

get the center of the ball

Definition at line 105 of file ball.h.

◆ center() [2/2]

template<int dim = 3>
const Point< dim > & WFMath::Ball< dim >::center ( ) const
inline

get the center of the ball

Definition at line 103 of file ball.h.

◆ fromAtlas()

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

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

Definition at line 280 of file atlasconv.h.

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

◆ getCenter()

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

Definition at line 100 of file ball.h.

◆ getCorner()

template<int dim = 3>
Point< dim > WFMath::Ball< dim >::getCorner ( size_t  ) const
inline

Definition at line 99 of file ball.h.

◆ isEqualTo()

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

Definition at line 185 of file ball.h.

◆ isValid()

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

Definition at line 90 of file ball.h.

◆ moveCenterTo()

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

Definition at line 115 of file ball.h.

◆ moveCornerTo()

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

Definition at line 114 of file ball.h.

◆ numCorners()

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

Definition at line 94 of file ball.h.

◆ operator!=()

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

Definition at line 88 of file ball.h.

◆ operator==()

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

Definition at line 87 of file ball.h.

◆ radius() [1/2]

template<int dim = 3>
CoordType & WFMath::Ball< dim >::radius ( )
inline

get the radius of the ball

Definition at line 109 of file ball.h.

◆ radius() [2/2]

template<int dim = 3>
CoordType WFMath::Ball< dim >::radius ( ) const
inline

get the radius of the ball

Definition at line 107 of file ball.h.

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

◆ rotateCenter() [1/2]

Ball< 3 > & WFMath::Ball< 3 >::rotateCenter ( const Quaternion )

Definition at line 44 of file ball.cpp.

◆ rotateCenter() [2/2]

template<int dim = 3>
Ball & WFMath::Ball< dim >::rotateCenter ( const RotMatrix< dim > &  )
inline

Definition at line 118 of file ball.h.

◆ rotateCorner() [1/2]

Ball< 3 > & WFMath::Ball< 3 >::rotateCorner ( const Quaternion ,
size_t   
)

Definition at line 39 of file ball.cpp.

◆ rotateCorner() [2/2]

template<int dim = 3>
Ball & WFMath::Ball< dim >::rotateCorner ( const RotMatrix< dim > &  ,
size_t   
)
inline

Definition at line 117 of file ball.h.

◆ rotatePoint() [1/2]

Ball< 3 > & WFMath::Ball< 3 >::rotatePoint ( const Quaternion q,
const Point< 3 > &  p 
)

Definition at line 49 of file ball.cpp.

◆ rotatePoint() [2/2]

template<int dim = 3>
Ball & WFMath::Ball< dim >::rotatePoint ( const RotMatrix< dim > &  m,
const Point< dim > &  p 
)
inline

Definition at line 119 of file ball.h.

◆ shift()

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

Definition at line 113 of file ball.h.

◆ toAtlas()

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

Create an Atlas object from the box.

Definition at line 309 of file atlasconv.h.

◆ toLocalCoords() [1/4]

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

Definition at line 148 of file ball.h.

◆ toLocalCoords() [2/4]

Ball< 3 > WFMath::Ball< 3 >::toLocalCoords ( const Point< 3 > &  origin,
const Quaternion rotation 
) const

Definition at line 60 of file ball.cpp.

◆ toLocalCoords() [3/4]

template<int dim = 3>
Ball WFMath::Ball< dim >::toLocalCoords ( const Point< dim > &  origin,
const RotMatrix< dim > &  rotation = RotMatrix<dim>().identity() 
) const
inline

Definition at line 145 of file ball.h.

◆ toLocalCoords() [4/4]

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

Definition at line 150 of file ball.h.

◆ toParentCoords() [1/4]

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

Definition at line 136 of file ball.h.

◆ toParentCoords() [2/4]

Ball< 3 > WFMath::Ball< 3 >::toParentCoords ( const Point< 3 > &  origin,
const Quaternion rotation 
) const

Definition at line 54 of file ball.cpp.

◆ toParentCoords() [3/4]

template<int dim = 3>
Ball WFMath::Ball< dim >::toParentCoords ( const Point< dim > &  origin,
const RotMatrix< dim > &  rotation = RotMatrix<dim>().identity() 
) const
inline

Definition at line 133 of file ball.h.

◆ toParentCoords() [4/4]

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

Definition at line 138 of file ball.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 Ball< dim > &  b,
const AxisBox< dim > &  a,
bool  proper 
)
friend

Definition at line 145 of file intersect.h.

◆ Contains [3/9]

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

Definition at line 505 of file polygon_intersect.cpp.

◆ Contains [4/9]

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

Definition at line 438 of file intersect.h.

◆ Contains [5/9]

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

Definition at line 179 of file intersect.h.

◆ Contains [6/9]

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

Definition at line 120 of file intersect.h.

◆ Contains [7/9]

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

Definition at line 488 of file polygon_intersect.cpp.

◆ Contains [8/9]

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

Definition at line 430 of file intersect.h.

◆ Contains [9/9]

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

Definition at line 313 of file intersect.h.

◆ Intersect [1/6]

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 [2/6]

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

Definition at line 113 of file intersect.h.

◆ Intersect [3/6]

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

Definition at line 170 of file intersect.h.

◆ Intersect [4/6]

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

Definition at line 471 of file polygon_intersect.cpp.

◆ Intersect [5/6]

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

Definition at line 422 of file intersect.h.

◆ Intersect [6/6]

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

Definition at line 281 of file intersect.h.

◆ operator>>

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

Definition at line 221 of file stream.h.


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