WFMath man page

WFMath — Generic library namespace.

Synopsis

Classes

class AxisBox
A dim dimensional axis-aligned box.
class Ball
A dim dimensional ball.
struct ColinearVectors
An error thrown by certain functions when passed parallel vectors.
class Line
A dim dimensional line.
struct ParseError
An error thrown by operator>>() when it fails to parse wfmath types.
class Point
A dim dimensional point.
class Polygon
A polygon, all of whose points lie in a plane, embedded in dim dimensions.
class Polygon< 2 >
The 2D specialization of the Polygon<> template.
class Quaternion
A normalized quaterion.
class RotBox
A dim dimensional box, lying at an arbitrary angle.
class RotMatrix
A dim dimensional rotation matrix. Technically, a member of the group O(dim).
class Segment
A line segment embedded in dim dimensions.
class Shape
A fake class which documents the generic parts of the WFMath interface.
class TimeDiff
The difference between two timestamps.
class TimeStamp
A time stamp.
class Vector
A dim dimensional vector.
class ZeroPrimitive
Utility class for providing zero primitives. This class will only work with simple structures such as Vector or Point which provide a m_elem structure. In order for it to access the m_elem structure it must be declared as a friend class of the class it will provide an instance of.

Typedefs

typedef float CoordType
Basic floating point type.

Functions

template<int dim, template< class, class > class container> AxisBox< dim > BoundingBox (const container< AxisBox< dim >, std::allocator< AxisBox< dim > > > &c)
Get the axis-aligned bounding box for a set of boxes.
template<int dim, template< class, class > class container> AxisBox< dim > BoundingBox (const container< Point< dim >, std::allocator< Point< dim > > > &c)
Get the axis-aligned bounding box for a set of points.
template<int dim, template< class, class > class container> Ball< dim > BoundingSphere (const container< Point< dim >, std::allocator< Point< dim > > > &c)
get the minimal bounding sphere for a set of points
template<int dim, template< class, class > class container> Ball< dim > BoundingSphereSloppy (const container< Point< dim >, std::allocator< Point< dim > > > &c)
get a bounding sphere for a set of points
template<class C > bool Equal (const C &c1, const C &c2, CoordType epsilon=numeric_constants< CoordType >::epsilon())
Test for equality up to precision epsilon.
template<int dim, template< class, class > class container> Point< dim > Barycenter (const container< Point< dim >, std::allocator< Point< dim > > > &c)
Find the center of a set of points, all weighted equally.
template<int dim, template< class, class > class container, template< class, class > class container2> Point< dim > Barycenter (const container< Point< dim >, std::allocator< Point< dim > > > &c, const container2< CoordType, std::allocator< CoordType > > &weights)
Find the center of a set of points with the given weights.
template<int dim> Point< dim > Midpoint (const Point< dim > &p1, const Point< dim > &p2, CoordType dist=0.5)

template<typename FloatT > FloatT GaussianConditional (FloatT mean, FloatT stddev, FloatT val)
Gives the conditional probability of the Gaussian distribution at position val.
template<typename FloatT > FloatT Gaussian (FloatT mean, FloatT stddev, FloatT val)
Gives the value of the Gaussian distribution at position val.
template<typename FloatT > FloatT PoissonConditional (FloatT mean, unsigned int step)
Gives the conditional probability of the Poisson distribution at position step.
template<typename FloatT > FloatT Poisson (FloatT mean, unsigned int step)
Gives the value of the Poisson distribution at position step.
template<typename FloatT > FloatT LogFactorial (unsigned int n)
Gives the natural log of n!
template<typename FloatT > FloatT Factorial (unsigned int n)
Gives n!
template<typename FloatT > FloatT LogGamma (FloatT z)
The natural log of Euler's Gamma function.
template<typename FloatT > FloatT Gamma (FloatT z)
Euler's Gamma function.
template<int dim> RotMatrix< dim > Prod (const RotMatrix< dim > &m1, const RotMatrix< dim > &m2)
returns m1 * m2
template<int dim> RotMatrix< dim > ProdInv (const RotMatrix< dim > &m1, const RotMatrix< dim > &m2)
returns m1 * m2^-1
template<int dim> RotMatrix< dim > InvProd (const RotMatrix< dim > &m1, const RotMatrix< dim > &m2)
returns m1^-1 * m2
template<int dim> RotMatrix< dim > InvProdInv (const RotMatrix< dim > &m1, const RotMatrix< dim > &m2)
returns m1^-1 * m2^-1
template<int dim> Vector< dim > Prod (const RotMatrix< dim > &m, const Vector< dim > &v)
returns m * v
template<int dim> Vector< dim > InvProd (const RotMatrix< dim > &m, const Vector< dim > &v)
returns m^-1 * v
template<int dim> Vector< dim > Prod (const Vector< dim > &v, const RotMatrix< dim > &m)
returns v * m
template<int dim> Vector< dim > ProdInv (const Vector< dim > &v, const RotMatrix< dim > &m)
return v * m^-1
template<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, std::streamsize precision=6)
Output a WFMath type as a string.
template<class C > void FromString (C &c, const std::string &s, std::streamsize=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<int dim> bool Parallel (const Vector< dim > &v1, const Vector< dim > &v2, bool &same_dir)
Check if two vectors are parallel.
template<int dim> bool Parallel (const Vector< dim > &v1, const Vector< dim > &v2)
Check if two vectors are parallel.
template<int dim> bool Perpendicular (const Vector< dim > &v1, const Vector< dim > &v2)
Check if two vectors are perpendicular.

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<int dim, template< class, class > class container, template< class, class > class container2> Point< dim > WFMath::Barycenter (const container< Point< dim >, std::allocator< Point< dim > > > & c, const container2< CoordType, std::allocator< 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.

References WFMath::Point< dim >::setValid().

template<class C > bool WFMath::Equal (const C & c1, const C & c2, CoordType epsilon = numeric_constants<CoordType>::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.

Referenced by WFMath::Segment< dim >::endpoint(), WFMath::Line< dim >::isEqualTo(), WFMath::RotBox< dim >::orientation(), Parallel(), WFMath::Ball< dim >::radius(), and WFMath::AxisBox< dim >::upperBound().

template<class C > void WFMath::FromString (C & c, const std::string & s, std::streamsize = 6) [inline]

Parse a WFMath type from a string. This uses operator>>() in its backend.

template<typename FloatT > FloatT WFMath::GaussianConditional (FloatT mean, FloatT stddev, FloatT 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<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.

References WFMath::Point< dim >::asPolar(), WFMath::Point< dim >::asSpherical(), WFMath::Point< dim >::polar(), WFMath::Point< dim >::spherical(), and WFMath::Point< dim >::z().

Referenced by WFMath::AxisBox< dim >::AxisBox(), BoundingSphereSloppy(), and WFMath::Segment< dim >::Segment().

template<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

References WFMath::Vector< dim >::Dot, and Equal().

Referenced by WFMath::Vector< 3 >::mirrorY(), and Parallel().

template<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

References Parallel(), WFMath::Vector< dim >::sloppyMagMax(), and WFMath::Vector< dim >::sloppyMagMaxSqrt().

template<typename FloatT > FloatT WFMath::PoissonConditional (FloatT 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<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

References InvProd().

template<class C > void WFMath::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 WFMath::ToString (const C & c, std::streamsize precision = 6) [inline]

Output a WFMath type as a string. This uses operator<<() in its backend.

Author

Generated automatically by Doxygen for WFMath from the source code.

Info

Fri Feb 5 2016 Version 1.0.2 WFMath