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

A fake class which documents the generic parts of the WFMath interface. More...

#include <shape.h>

Public Member Functions

 Shape (const Shape< dim > &s)
 
Shapeoperator= (const Shape &a)
 
bool isEqualTo (const Shape &s, CoordType tolerance=numeric_constants< CoordType >::epsilon()) const
 generic: check if two classes are equal, up to a given tolerance More...
 
bool operator== (const Shape &s) const
 generic: check if two classes are equal, up to tolerance WFMATH_EPSILON More...
 
bool operator!= (const Shape &s) const
 generic: check if two classes are not equal, up to tolerance WFMATH_EPSILON More...
 
bool isValid () const
 generic: returns true if the class instance has been initialized More...
 
size_t numCorners () const
 shape: return the number of corners in the shape. More...
 
Point< dim > getCorner (size_t i) const
 shape: return the position of the i'th corner, where 0 <= i < numCorners() More...
 
Point< dim > getCenter () const
 shape: return the position of the center of the shape More...
 
Shapeshift (const Vector< dim > &v)
 shape: move the shape by an amount given by the Vector v More...
 
ShapemoveCornerTo (const Point< dim > &p, size_t corner)
 shape: move the shape, moving the given corner to the Point p More...
 
ShapemoveCenterTo (const Point< dim > &p)
 shape: move the shape, moving the center to the Point p More...
 
ShaperotateCorner (const RotMatrix< dim > &m, size_t corner)
 shape: rotate the shape while holding the given corner fixed More...
 
ShaperotateCenter (const RotMatrix< dim > &m)
 shape: rotate the shape while holding the center fixed More...
 
ShaperotatePoint (const RotMatrix< dim > &m, const Point< dim > &p)
 shape: rotate the shape while holding the Point p fixed. More...
 
AxisBox< dim > boundingBox () const
 shape: return the minimal axis-aligned bounding box More...
 
Ball< dim > boundingSphere () const
 shape: return the minimal bounding sphere More...
 
Ball< dim > boundingSphereSloppy () const
 

Friends

std::ostream & operator (std::ostream &os, const Shape &s)
 generic: Print an instance to a stream More...
 
std::istream & operator>> (std::istream &is, Shape &s)
 generic: Parse an instance from a stream More...
 
bool Intersect (Shape< dim > &s1, Shape< dim > &s2, bool proper)
 shape: Returns true if the two shapes intersect. More...
 
bool Contains (Shape< dim > &s1, Shape< dim > &s2, bool proper)
 shape: Returns true if the first shape contains the second. More...
 

Detailed Description

template<const int dim>
class WFMath::Shape< dim >

A fake class which documents the generic parts of the WFMath interface.

This fake class documents two parts of the WFMath generic class interface. With a few exceptions (e.g. classes derived from std::exception), every class in WFMath implements the part of the interface labeled as 'generic'. The 'shape' interface is implemented by several classes, which identify themselves in their own documentation. Every class which implements the 'shape' interface also implements the 'generic' interface. Classes will not generally document their generic and shape interface functions.

Definition at line 56 of file shape.h.

Member Function Documentation

◆ boundingBox()

template<const int dim>
AxisBox<dim> WFMath::Shape< dim >::boundingBox ( ) const

shape: return the minimal axis-aligned bounding box

◆ boundingSphere()

template<const int dim>
Ball<dim> WFMath::Shape< dim >::boundingSphere ( ) const

shape: return the minimal bounding sphere

◆ boundingSphereSloppy()

template<const int dim>
Ball<dim> WFMath::Shape< dim >::boundingSphereSloppy ( ) const

shape: return an approximate bounding sphere, guaranteed to contain the minimal bounding sphere boundingSphereSloppy() uses SloppyDistance() instead of Distance() to calculate it's radius, except in cases like Point<> and Ball<> where it would be silly. Thus, the result of boundingSphereSloppy() is guaranteed to contain the result of boundingSphere().

◆ getCenter()

template<const int dim>
Point<dim> WFMath::Shape< dim >::getCenter ( ) const

shape: return the position of the center of the shape

Referenced by WFMath::Shape< dim >::moveCenterTo(), and WFMath::Shape< dim >::rotateCenter().

◆ getCorner()

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

shape: return the position of the i'th corner, where 0 <= i < numCorners()

Referenced by WFMath::Shape< dim >::moveCornerTo(), and WFMath::Shape< dim >::rotateCorner().

◆ isEqualTo()

template<const int dim>
bool WFMath::Shape< dim >::isEqualTo ( const Shape< dim > &  s,
CoordType  tolerance = numeric_constantsCoordType >::epsilon() 
) const

generic: check if two classes are equal, up to a given tolerance

Referenced by WFMath::Shape< dim >::operator!=(), and WFMath::Shape< dim >::operator==().

◆ isValid()

template<const int dim>
bool WFMath::Shape< dim >::isValid ( ) const
inline

generic: returns true if the class instance has been initialized

Definition at line 85 of file shape.h.

◆ moveCenterTo()

template<const int dim>
Shape& WFMath::Shape< dim >::moveCenterTo ( const Point< dim > &  p)
inline

shape: move the shape, moving the center to the Point p

The center is defined by getCenter()

Definition at line 115 of file shape.h.

References WFMath::Shape< dim >::getCenter(), and WFMath::Shape< dim >::shift().

◆ moveCornerTo()

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

shape: move the shape, moving the given corner to the Point p

The corner in question is getCorner(corner).

Definition at line 109 of file shape.h.

References WFMath::Shape< dim >::getCorner(), and WFMath::Shape< dim >::shift().

◆ numCorners()

template<const int dim>
size_t WFMath::Shape< dim >::numCorners ( ) const

shape: return the number of corners in the shape.

For many shape classes, this is a fixed constant

◆ operator!=()

template<const int dim>
bool WFMath::Shape< dim >::operator!= ( const Shape< dim > &  s) const
inline

generic: check if two classes are not equal, up to tolerance WFMATH_EPSILON

Definition at line 82 of file shape.h.

References WFMath::Shape< dim >::isEqualTo().

◆ operator==()

template<const int dim>
bool WFMath::Shape< dim >::operator== ( const Shape< dim > &  s) const
inline

generic: check if two classes are equal, up to tolerance WFMATH_EPSILON

Definition at line 80 of file shape.h.

References WFMath::Shape< dim >::isEqualTo().

◆ rotateCenter()

template<const int dim>
Shape& WFMath::Shape< dim >::rotateCenter ( const RotMatrix< dim > &  m)
inline

shape: rotate the shape while holding the center fixed

The center is defined by getCenter()

Definition at line 129 of file shape.h.

References WFMath::Shape< dim >::getCenter(), and WFMath::Shape< dim >::rotatePoint().

◆ rotateCorner()

template<const int dim>
Shape& WFMath::Shape< dim >::rotateCorner ( const RotMatrix< dim > &  m,
size_t  corner 
)
inline

shape: rotate the shape while holding the given corner fixed

The corner in question is getCorner(corner).

Definition at line 123 of file shape.h.

References WFMath::Shape< dim >::getCorner(), and WFMath::Shape< dim >::rotatePoint().

◆ rotatePoint()

template<const int dim>
Shape& WFMath::Shape< dim >::rotatePoint ( const RotMatrix< dim > &  m,
const Point< dim > &  p 
)

shape: rotate the shape while holding the Point p fixed.

Note that p can be any Point, it does not have to lie within the shape.

Referenced by WFMath::Shape< dim >::rotateCenter(), and WFMath::Shape< dim >::rotateCorner().

◆ shift()

template<const int dim>
Shape& WFMath::Shape< dim >::shift ( const Vector< dim > &  v)

shape: move the shape by an amount given by the Vector v

Referenced by WFMath::Shape< dim >::moveCenterTo(), and WFMath::Shape< dim >::moveCornerTo().

Friends And Related Function Documentation

◆ Contains

template<const int dim>
bool Contains ( Shape< dim > &  s1,
Shape< dim > &  s2,
bool  proper 
)
friend

shape: Returns true if the first shape contains the second.

If the 'proper' argument is true, the inner shape is not contained if it touches the boundary of the outer shape. Otherwise, it does. Therefore, any shape contains itself (Contains(foo, foo, false) == true), but no shape contains itself properly (Contains(foo, foo, true) == false). Because of this, an empty shape (e.g. a Polygon with zero corners) is properly contained by any other shape. A Point, or any single point shape (e.g. a Segment where the endpoints are equal) properly contains an empty shape, and contains (but not properly) any other single point shape which occupies the same point. The two shapes do not have to be the same class, but must have the same dimension.

◆ Intersect

template<const int dim>
bool Intersect ( Shape< dim > &  s1,
Shape< dim > &  s2,
bool  proper 
)
friend

shape: Returns true if the two shapes intersect.

If the 'proper' argument is true, shapes which only touch on their boundary do not count as intersecting. If it is false, they do. This function is symmetric in its first two arguments (Intersect(a, b, proper) == Intersect(b, a, proper)). The two shapes do not have to be the same class, but must have the same dimension.

◆ operator

template<const int dim>
std::ostream& operator ( std::ostream &  os,
const Shape< dim > &  s 
)
friend

generic: Print an instance to a stream

◆ operator>>

template<const int dim>
std::istream& operator>> ( std::istream &  is,
Shape< dim > &  s 
)
friend

generic: Parse an instance from a stream


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