Tekkotsu Homepage
Demos
Overview
Downloads
Dev. Resources
Reference
Credits

mathutils Namespace Reference

a variety of handy mathematical functions, many of which are templated More...

Functions

float distance (float x1, float y1, float x2, float y2)
 euclidean distance of two points, see squareDistance()
double distance (double x1, double y1, double x2, double y2)
 euclidean distance of two points, see squareDistance()
template<class num >
num limitRange (num n, num low, num high)
 Clips n to a minimum of low or maximum of high.
template<class num >
num log2t (num x)
 Returns the log base 2 of a number.
template<>
float log2t (float x)
 returns the log base 2 for a 'float' value
template<>
double log2t (double x)
 returns the log base 2 for a 'double' value
double deg2rad (double x)
 converts from degrees to radians
double rad2deg (double x)
 converts from radians to degrees
float deg2rad (float x)
 converts from degrees to radians
float rad2deg (float x)
 converts from radians to degrees
template<class num >
num normalizeAngle (num value)
 Will set a to be between (-pi,pi) (inclusive), just like atan2().
float sampleRange (float min, float max)
 Chooses a number in the range [min,max) (exclusive upper bound).
double sampleRange (double min, double max)
 Chooses a number in the range [min,max) (exclusive upper bound).
template<class num >
num sampleInteger (num min, num max)
 Chooses a number in the range [min,max) (exclusive upper bound).
template<class C >
C::value_type::first_type weightedPick (const C &c)
 Pass a collection of std::pair<value,weight> (map, vector, etc.), returns a value based on a weighted sample.

Detailed Description

a variety of handy mathematical functions, many of which are templated


Function Documentation

float mathutils::deg2rad ( float  x  ) 

converts from degrees to radians

Definition at line 79 of file mathutils.h.

double mathutils::distance ( double  x1,
double  y1,
double  x2,
double  y2 
)

euclidean distance of two points, see squareDistance()

Definition at line 29 of file mathutils.h.

float mathutils::distance ( float  x1,
float  y1,
float  x2,
float  y2 
)

euclidean distance of two points, see squareDistance()

Definition at line 24 of file mathutils.h.

template<class num >
num mathutils::limitRange ( num  n,
num  low,
num  high 
)

Clips n to a minimum of low or maximum of high.

If low and high are inverted, high is returned.

Definition at line 36 of file mathutils.h.

Referenced by WaypointEngine::computeNewVelocity().

template<>
double mathutils::log2t ( double  x  ) 

returns the log base 2 for a 'double' value

Definition at line 64 of file mathutils.h.

template<>
float mathutils::log2t ( float  x  ) 

returns the log base 2 for a 'float' value

Definition at line 59 of file mathutils.h.

template<class num >
num mathutils::log2t ( num  x  ) 

Returns the log base 2 of a number.

This template implementation does a bit shifting method appropriate for integers. Specializations are provided for float and double to use the 'real' log()

Definition at line 46 of file mathutils.h.

template<class num >
num mathutils::normalizeAngle ( num  value  ) 

Will set a to be between (-pi,pi) (inclusive), just like atan2().

This is only efficient if we expect that the angle is already close to the range... otherwise use fmod... See also Measures.h, this normalize is identical to the AngSignPi::normalize()

Definition at line 92 of file mathutils.h.

Referenced by Waypoint::apply(), WaypointEngine::computeCurrentPosition(), WaypointEngine::computeIdeal(), and WaypointEngine::computeNewVelocity().

float mathutils::rad2deg ( float  x  ) 

converts from radians to degrees

Definition at line 84 of file mathutils.h.

template<class num >
num mathutils::sampleInteger ( num  min,
num  max 
)

Chooses a number in the range [min,max) (exclusive upper bound).

Definition at line 145 of file mathutils.h.

double mathutils::sampleRange ( double  min,
double  max 
)

Chooses a number in the range [min,max) (exclusive upper bound).

Definition at line 140 of file mathutils.h.

float mathutils::sampleRange ( float  min,
float  max 
)

Chooses a number in the range [min,max) (exclusive upper bound).

Definition at line 136 of file mathutils.h.

Referenced by weightedPick().

template<class C >
C::value_type::first_type mathutils::weightedPick ( const C &  c  ) 

Pass a collection of std::pair<value,weight> (map, vector, etc.), returns a value based on a weighted sample.

Throws an exception if the collection is empty; if all weights are zero, performs a uniform sampling.

Definition at line 154 of file mathutils.h.


Tekkotsu v5.1CVS
Generated Mon May 9 04:59:24 2016 by Doxygen 1.6.3