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

A dim dimensional point. More...

#include <point.h>

Public Member Functions

 Point ()
 Construct an uninitialized point. More...
 
 Point (const Point &)=default
 Construct a copy of a point. More...
 
 Point (const AtlasInType &a)
 Construct a point from an object passed by Atlas. More...
 
 Point (const Vector< dim > &vector)
 Construct a point from a vector. More...
 
AtlasOutType toAtlas () const
 Create an Atlas object from the point. More...
 
void fromAtlas (const AtlasInType &a)
 Set the point's value to that given by an Atlas object. More...
 
Pointoperator= (const Point &rhs)=default
 
bool isEqualTo (const Point &p, CoordType epsilon=numeric_constants< CoordType >::epsilon()) const
 
bool operator== (const Point &rhs) const
 
bool operator!= (const Point &rhs) const
 
bool isValid () const
 
void setValid (bool valid=true)
 make isValid() return true if you've initialized the point by hand More...
 
PointsetToOrigin ()
 Set point to (0,0,...,0) More...
 
Pointrotate (const RotMatrix< dim > &m, const Point &p)
 Rotate about point p. More...
 
size_t numCorners () const
 
Point< dim > getCorner (size_t) const
 
Point< dim > getCenter () const
 
Point shift (const Vector< dim > &v)
 
Point moveCornerTo (const Point &p, size_t)
 
Point moveCenterTo (const Point &p)
 
PointrotateCorner (const RotMatrix< dim > &, size_t)
 
PointrotateCenter (const RotMatrix< dim > &)
 
PointrotatePoint (const RotMatrix< dim > &m, const Point &p)
 
Pointrotate (const Quaternion &q, const Point &p)
 
PointrotateCorner (const Quaternion &, size_t)
 
PointrotateCenter (const Quaternion &)
 
PointrotatePoint (const Quaternion &q, const Point &p)
 
AxisBox< dim > boundingBox () const
 
Ball< dim > boundingSphere () const
 
Ball< dim > boundingSphereSloppy () const
 
Point toParentCoords (const Point &origin, const RotMatrix< dim > &rotation=RotMatrix< dim >().identity()) const
 
Point toParentCoords (const AxisBox< dim > &coords) const
 
Point toParentCoords (const RotBox< dim > &coords) const
 
Point toLocalCoords (const Point &origin, const RotMatrix< dim > &rotation=RotMatrix< dim >().identity()) const
 
Point toLocalCoords (const AxisBox< dim > &coords) const
 
Point toLocalCoords (const RotBox< dim > &coords) const
 
Point toParentCoords (const Point &origin, const Quaternion &rotation) const
 
Point toLocalCoords (const Point &origin, const Quaternion &rotation) const
 
CoordType operator[] (const int i) const
 Access the i'th coordinate of the point. More...
 
CoordTypeoperator[] (const int i)
 Access the i'th coordinate of the point. More...
 
 Point (CoordType x, CoordType y)
 2D only: construct a point from its (x, y) coordinates More...
 
 Point (CoordType x, CoordType y, CoordType z)
 3D only: construct a point from its (x, y, z) coordinates More...
 
CoordType x () const
 access the first component of a point More...
 
CoordTypex ()
 access the first component of a point More...
 
CoordType y () const
 access the second component of a point More...
 
CoordTypey ()
 access the second component of a point More...
 
CoordType z () const
 access the third component of a point More...
 
CoordTypez ()
 access the third component of a point More...
 
Pointpolar (CoordType r, CoordType theta)
 2D only: construct a vector from polar coordinates More...
 
void asPolar (CoordType &r, CoordType &theta) const
 2D only: convert a vector to polar coordinates More...
 
Pointpolar (CoordType r, CoordType theta, CoordType z)
 3D only: construct a vector from polar coordinates More...
 
void asPolar (CoordType &r, CoordType &theta, CoordType &z) const
 3D only: convert a vector to polar coordinates More...
 
Pointspherical (CoordType r, CoordType theta, CoordType phi)
 3D only: construct a vector from spherical coordinates More...
 
void asSpherical (CoordType &r, CoordType &theta, CoordType &phi) const
 3D only: convert a vector to spherical coordinates More...
 
const CoordTypeelements () const
 
Point< 2 > & polar (CoordType r, CoordType theta)
 
void asPolar (CoordType &r, CoordType &theta) const
 
Point< 3 > & polar (CoordType r, CoordType theta, CoordType z)
 
void asPolar (CoordType &r, CoordType &theta, CoordType &z) const
 
Point< 3 > & spherical (CoordType r, CoordType theta, CoordType phi)
 
void asSpherical (CoordType &r, CoordType &theta, CoordType &phi) const
 
Point< 3 > & rotate (const Quaternion &q, const Point< 3 > &p)
 
Point< 3 > & rotatePoint (const Quaternion &q, const Point< 3 > &p)
 
Point< 3 > toLocalCoords (const Point< 3 > &origin, const Quaternion &rotation) const
 
Point< 3 > toParentCoords (const Point< 3 > &origin, const Quaternion &rotation) const
 
CoordType z () const
 
CoordTypez ()
 
 Point (CoordType x, CoordType y)
 
 Point (CoordType x, CoordType y, CoordType z)
 
Point< 2 > & polar (CoordType r, CoordType theta)
 
void asPolar (CoordType &r, CoordType &theta) const
 
Point< 3 > & polar (CoordType r, CoordType theta, CoordType z)
 
void asPolar (CoordType &r, CoordType &theta, CoordType &z) const
 
Point< 3 > & spherical (CoordType r, CoordType theta, CoordType phi)
 
void asSpherical (CoordType &r, CoordType &theta, CoordType &phi) const
 

Static Public Member Functions

static const Point< dim > & ZERO ()
 Provides a global instance preset to zero. More...
 

Friends

class ZeroPrimitive< Point< dim > >
 
std::ostream & operator (std::ostream &os, const Point &p)
 
std::istream & operator>> (std::istream &is, Point &p)
 
Vector< dim > operator- (const Point &c1, const Point &c2)
 
Point operator+ (const Point &c, const Vector< dim > &v)
 
Point operator- (const Point &c, const Vector< dim > &v)
 
Point operator+ (const Vector< dim > &v, const Point &c)
 
Pointoperator+= (Point &p, const Vector< dim > &rhs)
 
Pointoperator-= (Point &p, const Vector< dim > &rhs)
 
CoordType SquaredDistance (const Point &p1, const Point &p2)
 Get the square of the distance from p1 to p2. More...
 
Point< dim > Midpoint (const Point &p1, const Point &p2, CoordType dist)
 Find a point on the line containing p1 and p2, by default the midpoint. More...
 

Detailed Description

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

A dim dimensional point.

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

Definition at line 95 of file point.h.

Constructor & Destructor Documentation

◆ Point() [1/8]

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

Construct an uninitialized point.

Definition at line 100 of file point.h.

◆ Point() [2/8]

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

Construct a copy of a point.

◆ Point() [3/8]

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

Construct a point from an object passed by Atlas.

Definition at line 184 of file atlasconv.h.

◆ Point() [4/8]

template<int dim>
WFMath::Point< dim >::Point ( const Vector< dim > &  vector)
inlineexplicit

Construct a point from a vector.

Definition at line 40 of file point_funcs.h.

◆ Point() [5/8]

template<int dim = 3>
WFMath::Point< dim >::Point ( CoordType  x,
CoordType  y 
)

2D only: construct a point from its (x, y) coordinates

◆ Point() [6/8]

template<int dim = 3>
WFMath::Point< dim >::Point ( CoordType  x,
CoordType  y,
CoordType  z 
)

3D only: construct a point from its (x, y, z) coordinates

◆ Point() [7/8]

WFMath::Point< 2 >::Point ( CoordType  x,
CoordType  y 
)
inline

Definition at line 308 of file point.h.

◆ Point() [8/8]

WFMath::Point< 3 >::Point ( CoordType  x,
CoordType  y,
CoordType  z 
)
inline

Definition at line 315 of file point.h.

Member Function Documentation

◆ asPolar() [1/4]

void WFMath::Point< 2 >::asPolar ( CoordType r,
CoordType theta 
) const

Definition at line 51 of file point.cpp.

◆ asPolar() [2/4]

template<int dim = 3>
void WFMath::Point< dim >::asPolar ( CoordType r,
CoordType theta 
) const

2D only: convert a vector to polar coordinates

◆ asPolar() [3/4]

void WFMath::Point< 3 >::asPolar ( CoordType r,
CoordType theta,
CoordType z 
) const

Definition at line 70 of file point.cpp.

◆ asPolar() [4/4]

template<int dim = 3>
void WFMath::Point< dim >::asPolar ( CoordType r,
CoordType theta,
CoordType z 
) const

3D only: convert a vector to polar coordinates

◆ asSpherical() [1/2]

void WFMath::Point< 3 >::asSpherical ( CoordType r,
CoordType theta,
CoordType phi 
) const

Definition at line 89 of file point.cpp.

◆ asSpherical() [2/2]

template<int dim = 3>
void WFMath::Point< dim >::asSpherical ( CoordType r,
CoordType theta,
CoordType phi 
) const

3D only: convert a vector to spherical coordinates

◆ boundingBox()

template<int dim>
AxisBox< dim > WFMath::Point< dim >::boundingBox
inline

Definition at line 187 of file axisbox_funcs.h.

◆ boundingSphere()

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

Definition at line 169 of file ball_funcs.h.

◆ boundingSphereSloppy()

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

Definition at line 175 of file ball_funcs.h.

◆ elements()

template<int dim = 3>
const CoordType * WFMath::Point< dim >::elements ( ) const
inline

Definition at line 258 of file point.h.

◆ fromAtlas()

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

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

Definition at line 190 of file atlasconv.h.

Referenced by WFMath::RotBox< dim >::fromAtlas().

◆ getCenter()

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

Definition at line 153 of file point.h.

◆ getCorner()

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

Definition at line 152 of file point.h.

◆ isEqualTo()

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

Definition at line 68 of file point_funcs.h.

◆ isValid()

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

Definition at line 127 of file point.h.

◆ moveCenterTo()

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

Definition at line 158 of file point.h.

◆ moveCornerTo()

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

Definition at line 156 of file point.h.

◆ numCorners()

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

Definition at line 151 of file point.h.

◆ operator!=()

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

Definition at line 125 of file point.h.

◆ operator==()

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

Definition at line 124 of file point.h.

◆ operator[]() [1/2]

template<int dim = 3>
CoordType & WFMath::Point< dim >::operator[] ( const int  i)
inline

Access the i'th coordinate of the point.

Definition at line 203 of file point.h.

◆ operator[]() [2/2]

template<int dim = 3>
CoordType WFMath::Point< dim >::operator[] ( const int  i) const
inline

Access the i'th coordinate of the point.

Definition at line 201 of file point.h.

◆ polar() [1/4]

Point< 2 > & WFMath::Point< 2 >::polar ( CoordType  r,
CoordType  theta 
)

Definition at line 42 of file point.cpp.

◆ polar() [2/4]

template<int dim = 3>
Point & WFMath::Point< dim >::polar ( CoordType  r,
CoordType  theta 
)

2D only: construct a vector from polar coordinates

◆ polar() [3/4]

Point< 3 > & WFMath::Point< 3 >::polar ( CoordType  r,
CoordType  theta,
CoordType  z 
)

Definition at line 60 of file point.cpp.

◆ polar() [4/4]

template<int dim = 3>
Point & WFMath::Point< dim >::polar ( CoordType  r,
CoordType  theta,
CoordType  z 
)

3D only: construct a vector from polar coordinates

◆ rotate() [1/2]

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

Definition at line 100 of file point.cpp.

◆ rotate() [2/2]

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

Rotate about point p.

Definition at line 146 of file point.h.

References WFMath::Prod().

◆ rotateCenter() [1/2]

template<int dim = 3>
Point & WFMath::Point< dim >::rotateCenter ( const Quaternion )
inline

Definition at line 169 of file point.h.

◆ rotateCenter() [2/2]

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

Definition at line 162 of file point.h.

◆ rotateCorner() [1/2]

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

Definition at line 167 of file point.h.

◆ rotateCorner() [2/2]

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

Definition at line 160 of file point.h.

◆ rotatePoint() [1/2]

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

Definition at line 106 of file point.cpp.

◆ rotatePoint() [2/2]

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

Definition at line 163 of file point.h.

◆ setToOrigin()

template<int dim>
Point< dim > & WFMath::Point< dim >::setToOrigin
inline

Set point to (0,0,...,0)

Definition at line 56 of file point_funcs.h.

◆ setValid()

template<int dim = 3>
void WFMath::Point< dim >::setValid ( bool  valid = true)
inline

make isValid() return true if you've initialized the point by hand

Definition at line 129 of file point.h.

Referenced by WFMath::Ball< dim >::Ball(), WFMath::Barycenter(), WFMath::BoundingBox(), WFMath::BoundingSphere(), WFMath::BoundingSphereSloppy(), and WFMath::AxisBox< dim >::setCorners().

◆ shift()

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

Definition at line 155 of file point.h.

◆ spherical() [1/2]

Point< 3 > & WFMath::Point< 3 >::spherical ( CoordType  r,
CoordType  theta,
CoordType  phi 
)

Definition at line 80 of file point.cpp.

◆ spherical() [2/2]

template<int dim = 3>
Point & WFMath::Point< dim >::spherical ( CoordType  r,
CoordType  theta,
CoordType  phi 
)

3D only: construct a vector from spherical coordinates

◆ toAtlas()

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

Create an Atlas object from the point.

Definition at line 203 of file atlasconv.h.

◆ toLocalCoords() [1/4]

template<int dim>
Point< dim > WFMath::Point< dim >::toLocalCoords ( const AxisBox< dim > &  coords) const

Definition at line 199 of file axisbox_funcs.h.

◆ toLocalCoords() [2/4]

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

Definition at line 188 of file point.h.

◆ toLocalCoords() [3/4]

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

Definition at line 112 of file point.cpp.

◆ toLocalCoords() [4/4]

template<int dim>
Point< dim > WFMath::Point< dim >::toLocalCoords ( const RotBox< dim > &  coords) const

Definition at line 109 of file rotbox_funcs.h.

◆ toParentCoords() [1/4]

template<int dim>
Point< dim > WFMath::Point< dim >::toParentCoords ( const AxisBox< dim > &  coords) const

Definition at line 193 of file axisbox_funcs.h.

◆ toParentCoords() [2/4]

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

Definition at line 178 of file point.h.

◆ toParentCoords() [3/4]

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

Definition at line 119 of file point.cpp.

◆ toParentCoords() [4/4]

template<int dim>
Point< dim > WFMath::Point< dim >::toParentCoords ( const RotBox< dim > &  coords) const

Definition at line 103 of file rotbox_funcs.h.

◆ x() [1/2]

template<int dim = 3>
CoordType & WFMath::Point< dim >::x ( )
inline

access the first component of a point

Definition at line 234 of file point.h.

◆ x() [2/2]

template<int dim = 3>
CoordType WFMath::Point< dim >::x ( ) const
inline

access the first component of a point

Definition at line 232 of file point.h.

◆ y() [1/2]

template<int dim = 3>
CoordType & WFMath::Point< dim >::y ( )
inline

access the second component of a point

Definition at line 238 of file point.h.

◆ y() [2/2]

template<int dim = 3>
CoordType WFMath::Point< dim >::y ( ) const
inline

access the second component of a point

Definition at line 236 of file point.h.

◆ z() [1/4]

template<int dim = 3>
CoordType & WFMath::Point< dim >::z ( )

access the third component of a point

◆ z() [2/4]

CoordType & WFMath::Point< 3 >::z ( )
inline

Definition at line 272 of file point.h.

◆ z() [3/4]

template<int dim = 3>
CoordType WFMath::Point< dim >::z ( ) const

access the third component of a point

◆ z() [4/4]

CoordType WFMath::Point< 3 >::z ( ) const
inline

Definition at line 266 of file point.h.

◆ ZERO()

template<int dim>
const Point< dim > & WFMath::Point< dim >::ZERO
static

Provides a global instance preset to zero.

Definition at line 48 of file point_funcs.h.

References WFMath::ZeroPrimitive< Shape >::getShape().

Friends And Related Function Documentation

◆ Midpoint

template<int dim = 3>
Point< dim > Midpoint ( const Point< dim > &  p1,
const Point< dim > &  p2,
CoordType  dist = 0.5 
)
friend

Find a point on the line containing p1 and p2, by default the midpoint.

The default value of 0.5 for dist gives the midpoint. A value of 0 gives p1, and 1 gives p2. Values of dist outside the [0, 1] range are allowed, and give points on the line which are not on the segment bounded by p1 and p2.

Definition at line 219 of file point_funcs.h.

◆ operator+ [1/2]

template<int dim = 3>
Point operator+ ( const Point< dim > &  c,
const Vector< dim > &  v 
)
friend

Definition at line 278 of file point.h.

◆ operator+ [2/2]

template<int dim = 3>
Point operator+ ( const Vector< dim > &  v,
const Point< dim > &  c 
)
friend

Definition at line 288 of file point.h.

◆ operator+=

template<int dim = 3>
Point & operator+= ( Point< dim > &  p,
const Vector< dim > &  rhs 
)
friend

Definition at line 100 of file point_funcs.h.

◆ operator- [1/2]

template<int dim = 3>
Point operator- ( const Point< dim > &  c,
const Vector< dim > &  v 
)
friend

Definition at line 298 of file point.h.

◆ operator- [2/2]

template<int dim = 3>
Vector< dim > operator- ( const Point< dim > &  c1,
const Point< dim > &  c2 
)
friend

Definition at line 86 of file point_funcs.h.

◆ operator-=

template<int dim = 3>
Point & operator-= ( Point< dim > &  p,
const Vector< dim > &  rhs 
)
friend

Definition at line 112 of file point_funcs.h.

◆ operator>>

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

Definition at line 180 of file stream.h.

◆ SquaredDistance

template<int dim = 3>
CoordType SquaredDistance ( const Point< dim > &  p1,
const Point< dim > &  p2 
)
friend

Get the square of the distance from p1 to p2.

Definition at line 124 of file point_funcs.h.

◆ ZeroPrimitive< Point< dim > >

template<int dim = 3>
friend class ZeroPrimitive< Point< dim > >
friend

Definition at line 315 of file point.h.


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