Main Page | Namespace List | Class List | File List | Namespace Members | Class Members

WFMath Namespace Reference

Generic library namespace. More...


Classes

class  WFMath::AxisBox< dim >
 A dim dimensional axis-aligned box. More...
class  WFMath::Ball< dim >
 A dim dimensional ball. More...
struct  WFMath::ColinearVectors< dim >
 An error thrown by certain functions when passed parallel vectors. More...
struct  WFMath::ParseError
 An error thrown by operator>>() when it fails to parse wfmath types. More...
class  WFMath::Point< dim >
 A dim dimensional point. More...
class  WFMath::Polygon< 2 >
 The 2D specialization of the Polygon<> template. More...
class  WFMath::Polygon< dim >
 A polygon, all of whose points lie in a plane, embedded in dim dimensions. More...
class  WFMath::Quaternion
 A normalized quaterion. More...
class  WFMath::RotBox< dim >
 A dim dimensional box, lying at an arbitrary angle. More...
class  WFMath::RotMatrix< dim >
 A dim dimensional rotation matrix. Technically, a member of the group O(dim). More...
class  WFMath::Segment< dim >
 A line segment embedded in dim dimensions. More...
class  WFMath::TimeDiff
 The difference between two timestamps. More...
class  WFMath::TimeStamp
 A time stamp. More...
class  WFMath::Vector< dim >
 A dim dimensional vector. More...
class  WFMath::Shape< dim >
 A fake class which documents the generic parts of the WFMath interface. More...

Typedefs

typedef float CoordType
 Basic floating point type.

Functions

template<const int dim, template< class > class container>
AxisBox< dim > BoundingBox (const container< AxisBox< dim > > &c)
 Get the axis-aligned bounding box for a set of boxes.
template<const int dim, template< class > class container>
AxisBox< dim > BoundingBox (const container< Point< dim > > &c)
 Get the axis-aligned bounding box for a set of points.
template<const int dim, template< class > class container>
Ball< dim > BoundingSphere (const container< Point< dim > > &c)
 get the minimal bounding sphere for a set of points
template<const int dim, template< class > class container>
Ball< dim > BoundingSphereSloppy (const container< Point< dim > > &c)
 get a bounding sphere for a set of points
template<class C>
bool Equal (const C &c1, const C &c2, double epsilon=WFMATH_EPSILON)
 Test for equality up to precision epsilon.
template<const int dim, template< class > class container>
Point< dim > Barycenter (const container< Point< dim > > &c)
 Find the center of a set of points, all weighted equally.
template<const int dim, template< class > class container, template< class > class container2>
Point< dim > Barycenter (const container< Point< dim > > &c, const container2< CoordType > &weights)
 Find the center of a set of points with the given weights.
template<const int dim>
Point< dim > Midpoint (const Point< dim > &p1, const Point< dim > &p2, CoordType dist=0.5)
double GaussianConditional (double mean, double stddev, double val)
 Gives the conditional probability of the Gaussian distribution at position val.
double Gaussian (double mean, double stddev, double val)
 Gives the value of the Gaussian distribution at position val.
double PoissonConditional (double mean, unsigned int step)
 Gives the conditional probability of the Poisson distribution at position step.
double Poisson (double mean, unsigned int step)
 Gives the value of the Poisson distribution at position step.
double LogFactorial (unsigned int n)
 Gives the natural log of n!
double Factorial (unsigned int n)
 Gives n!
double LogGamma (double z)
 The natural log of Euler's Gamma function.
double Gamma (double z)
 Euler's Gamma function.
template<const int dim>
RotMatrix< dim > Prod (const RotMatrix< dim > &m1, const RotMatrix< dim > &m2)
 returns m1 * m2
template<const int dim>
RotMatrix< dim > ProdInv (const RotMatrix< dim > &m1, const RotMatrix< dim > &m2)
 returns m1 * m2^-1
template<const int dim>
RotMatrix< dim > InvProd (const RotMatrix< dim > &m1, const RotMatrix< dim > &m2)
 returns m1^-1 * m2
template<const int dim>
RotMatrix< dim > InvProdInv (const RotMatrix< dim > &m1, const RotMatrix< dim > &m2)
 returns m1^-1 * m2^-1
template<const int dim>
Vector< dim > Prod (const RotMatrix< dim > &m, const Vector< dim > &v)
 returns m * v
template<const int dim>
Vector< dim > InvProd (const RotMatrix< dim > &m, const Vector< dim > &v)
 returns m^-1 * v
template<const int dim>
Vector< dim > Prod (const Vector< dim > &v, const RotMatrix< dim > &m)
 returns v * m
template<const int dim>
Vector< dim > ProdInv (const Vector< dim > &v, const RotMatrix< dim > &m)
 return v * m^-1
template<const int dim>
RotMatrix< dim > operator * (const RotMatrix< dim > &m1, const RotMatrix< dim > &m2)
 returns m1 * m2
template<class C>
void Shuffle (std::vector< C > &v)
 Randomly reorder the contents of a std::vector.
template<class C>
std::string ToString (const C &c, unsigned int precision=6)
 Output a WFMath type as a string.
template<class C>
void FromString (C &c, const std::string &s, unsigned int precision=6)
 Parse a WFMath type from a string.
CoordType Cross (const Vector< 2 > &v1, const Vector< 2 > &v2)
 2D only: get the z component of the cross product of two vectors
Vector< 3 > Cross (const Vector< 3 > &v1, const Vector< 3 > &v2)
 3D only: get the cross product of two vectors
template<const int dim>
bool Parallel (const Vector< dim > &v1, const Vector< dim > &v2, bool &same_dir)
 Check if two vectors are parallel.
template<const int dim>
bool Parallel (const Vector< dim > &v1, const Vector< dim > &v2)
 Check if two vectors are parallel.
template<const int dim>
bool Perpendicular (const Vector< dim > &v1, const Vector< dim > &v2)
 Check if two vectors are perpendicular.

Variables

const double Pi = 3.14159265358979323846264338327950288419716939937508
 The constant pi.
const double SqrtPi = 1.77245385090551602729816748334114518279754945612237
 The square root of pi.
const double LogPi = 1.14472988584940017414342735135305871164729481291530
 The natural logarithm of pi.
const double Sqrt2 = 1.41421356237309504880168872420969807856967187537693
 The square root of 2.
const double Sqrt3 = 1.73205080756887729352744634150587236694280525381037
 The square root of 3.
const double Log2 = 0.69314718055994530941723212145817656807550013436025
 The natural logarithm of 2.


Detailed Description

Generic library namespace.

Timing related primitives in a portable fashion - note this is for interval / elapsed time measurement, not displaying a human readable time.


Function Documentation

template<const int dim, template< class > class container, template< class > class container2>
Point< dim > WFMath::Barycenter const container< Point< dim > > &  c,
const container2< CoordType > &  weights
 

Find the center of a set of points with the given weights.

If the number of points and the number of weights are not equal, the excess of either is ignored. The weights (or that subset which is used, if there are more weights than points), must not sum to zero.

template<class C>
bool Equal const C &  c1,
const C &  c2,
double  epsilon = WFMATH_EPSILON
[inline]
 

Test for equality up to precision epsilon.

Returns true if the difference between the numbers is less than epsilon. Note that epsilon is multiplied by 2 raised to the power of the exponent of the smaller number. So, for example, Equal(0.00010000, 0.00010002, 1.0e-4) will not compare equal, but Equal(0.00010000, 0.00010002, 1.0e-3) will.

template<class C>
void FromString C &  c,
const std::string &  s,
unsigned int  precision = 6
[inline]
 

Parse a WFMath type from a string.

This uses operator>>() in its backend.

double GaussianConditional double  mean,
double  stddev,
double  val
 

Gives the conditional probability of the Gaussian distribution at position val.

The probability that a Gaussian random variable will fall between val and val + delta, given that it is already known to be not less than val, is given by this function multiplied by delta (for small delta).

template<const int dim>
Point< dim > WFMath::Midpoint const Point< dim > &  p1,
const Point< dim > &  p2,
CoordType  dist = 0.5
[inline]
 

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.

template<const int dim>
bool WFMath::Parallel const Vector< dim > &  v1,
const Vector< dim > &  v2
[inline]
 

Check if two vectors are parallel.

Convienience wrapper if you don't care about same_dir

template<const int dim>
bool WFMath::Parallel const Vector< dim > &  v1,
const Vector< dim > &  v2,
bool &  same_dir
[inline]
 

Check if two vectors are parallel.

Returns true if the vectors are parallel. For parallel vectors, same_dir is set to true if they point the same direction, and false if they point opposite directions

double PoissonConditional double  mean,
unsigned int  step
 

Gives the conditional probability of the Poisson distribution at position step.

Returns the probability that a Poisson random variable will have value step, given that it is already known not to be less than step.

template<const int dim>
Vector< dim > WFMath::Prod const Vector< dim > &  v,
const RotMatrix< dim > &  m
[inline]
 

returns v * m

This is the function to use to rotate a Vector v using a Matrix m

template<class C>
void Shuffle std::vector< C > &  v  ) 
 

Randomly reorder the contents of a std::vector.

For things like shuffling a deck of cards, etc.

template<class C>
std::string ToString const C &  c,
unsigned int  precision = 6
[inline]
 

Output a WFMath type as a string.

This uses operator<<() in its backend.


Generated on Wed Oct 27 06:58:56 2004 for WFMath by  doxygen 1.3.9.1