Parasol Planning Library (PPL)
Data Structures
MPUtils.h File Reference
#include <functional>
#include <iostream>
#include <limits>
#include <map>
#include <memory>
#include <string>
#include <algorithm>
#include <containers/sequential/graph/algorithms/connected_components.h>
#include "Vector.h"
#include "IOUtils.h"
#include <boost/math/special_functions/binomial.hpp>
#include <boost/math/special_functions/factorials.hpp>
Include dependency graph for MPUtils.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  CompareSecond< T, U >
 
struct  CompareSecondReverse< T, U >
 
struct  NullOutputIterator
 

MPUtils

#define MAX_INT   std::numeric_limits<int>::max()
 
#define MAX_DBL   std::numeric_limits<double>::max()
 
template<typename T >
const T Epsilon (const T &_t1, const T &_t2)
 
double DRand ()
 
long LRand ()
 
long MRand ()
 
double GRand (bool _reset=false)
 
double GaussianDistribution (double _mean, double _stdev)
 Same as GRand, but one can specify the mean and stdev of the distribution. More...
 
void SRand (const unsigned long _seed)
 Use seedval as the seed. More...
 
double Normalize (const double &_a)
 Normalize a value into the range [-1,1). More...
 
double TriangleHeight (const Point3d &_a, const Point3d &_b, const Point3d &_c)
 
bool PtInTriangle (const Point2d &_a, const Point2d &_b, const Point2d &_c, const Point2d &_p)
 
bool PtInTriangle (const Point2d &_a, const Point2d &_b, const Point2d &_c, const Point2d &_p, double &_u, double &_v)
 
Point3d GetPtFromBarycentricCoords (const Point3d &_a, const Point3d &_b, const Point3d &_c, double _u, double _v)
 
double NormalizeTheta (double _theta)
 
template<class CfgType , class Environment >
bool IsWithinResolution (const CfgType &_cfg1, const CfgType &_cfg2, Environment *_env)
 
template<class CfgType >
CfgType ClosestPtOnLineSegment (const CfgType &_ref, const CfgType &_p1, const CfgType &_p2)
 
bool binom_test (double _alpha, size_t _n, size_t _k, double _p)
 
double binomial (size_t _n, size_t _k, double _p)
 
template<class RandomIterator , class T , class Compare = std::less<T>>
RandomIterator BinarySearch (RandomIterator _begin, RandomIterator _end, const T &_value, Compare _comparator=Compare())
 
std::vector< CfgLoadPath (const std::string &_filename, Robot *_robot)
 Loads a configuration path from a file for a dynamic obstacle. More...
 
template<typename T >
Identity (const T &_t) noexcept
 

Macro Definition Documentation

◆ MAX_DBL

#define MAX_DBL   std::numeric_limits<double>::max()

◆ MAX_INT

#define MAX_INT   std::numeric_limits<int>::max()

Function Documentation

◆ BinarySearch()

template<class RandomIterator , class T , class Compare = std::less<T>>
RandomIterator BinarySearch ( RandomIterator  _begin,
RandomIterator  _end,
const T &  _value,
Compare  _comparator = Compare() 
)

Search a random-access container using binary search. Needed for std::vector because std::find cannot know whether the elements are sorted without doing a linear scan.

◆ binom_test()

bool binom_test ( double  _alpha,
size_t  _n,
size_t  _k,
double  _p 
)

Given a significance level, the number of trials, the number of successes and the probability of success. Conduct a two-sided p-test.

Parameters
_alphaThe reference configuration.
_nThe number of trials conducted
_kThe number of trial successes
_pThe probability of success for the null. The assumed true value of success
Returns
If we fail to reject the null (true) and if we have enough evidence to reject the null (false).

◆ binomial()

double binomial ( size_t  _n,
size_t  _k,
double  _p 
)

Given the number of trials, the number of successes, and the probability of success, returns the probability density function evaluated k.

Parameters
_nThe number of trials
_kThe number of successes we are interested in
_pThe probability of success
Returns
The pdf of a binomial random variable evaluated at binom(n,k)

◆ ClosestPtOnLineSegment()

template<class CfgType >
CfgType ClosestPtOnLineSegment ( const CfgType &  _ref,
const CfgType &  _p1,
const CfgType &  _p2 
)

Given a reference configuration and a line segment in C-space, find the closest point on the line segment to the reference configuration.

Parameters
_refThe reference configuration.
_p1The first endpoint of the line segment.
_p2The second endpoint of the line segment.
Returns
The closest point to _ref on the segment from _p1 to _p2.

◆ DRand()

double DRand ( )

Return non-negative double-prevision floating-point values uniformly distributed over the interval [0.0, 1.0).

◆ Epsilon()

template<typename T >
const T Epsilon ( const T &  _t1,
const T &  _t2 
)

Variable resolution epsilon for doubles and float. This number is based upon the resolution of the lower magnitude value between _t1 and _t2.

◆ GaussianDistribution()

double GaussianDistribution ( double  _mean,
double  _stdev 
)

Same as GRand, but one can specify the mean and stdev of the distribution.

◆ GetPtFromBarycentricCoords()

Point3d GetPtFromBarycentricCoords ( const Point3d &  _a,
const Point3d &  _b,
const Point3d &  _c,
double  _u,
double  _v 
)

Given triange defined by _a, _b, _c, return the point inside triangle defined by barycentric coordinates _u, _v.

◆ GRand()

double GRand ( bool  _reset = false)

Return normally(gaussian) distributed random numbers via the Marsaglia polar method.

Parameters
_resetIf true, clear internal cache and return 0.

◆ Identity()

template<typename T >
T Identity ( const T &  _t)
noexcept

◆ IsWithinResolution()

template<class CfgType , class Environment >
bool IsWithinResolution ( const CfgType &  _cfg1,
const CfgType &  _cfg2,
Environment _env 
)

Determine whether two configurations are within a resolution unit of each other.

Parameters
_cfg1The first configuration.
_cfg2The second configuration.
Returns
A bool indicating whether the two cfgs are separated by no more than one resolution unit.

◆ LoadPath()

std::vector<Cfg> LoadPath ( const std::string &  _filename,
Robot _robot 
)

Loads a configuration path from a file for a dynamic obstacle.

◆ LRand()

long LRand ( )

Return non-negative long integers uniformly distributed over the interval [0, 2**31).

◆ MRand()

long MRand ( )

Return signed long integers uniformly distributed over the interval [-2**31, 2**31).

◆ Normalize()

double Normalize ( const double &  _a)

Normalize a value into the range [-1,1).

◆ NormalizeTheta()

double NormalizeTheta ( double  _theta)

Normalize an angle to standard range.

Parameters
_thetaThe angle to normalize.
Returns
Normalized representation of _theta in the range -PI to PI.

◆ PtInTriangle() [1/2]

bool PtInTriangle ( const Point2d &  _a,
const Point2d &  _b,
const Point2d &  _c,
const Point2d &  _p 
)

Check if a 2d point lies inside the triangle defined by three other points.

Parameters
_aThe first triangle vertex.
_bThe second triangle vertex.
_cThe third triangle vertex.
_pThe query point.
Returns
True if _p is inside triangle _a_b_c, or false otherwise.

◆ PtInTriangle() [2/2]

bool PtInTriangle ( const Point2d &  _a,
const Point2d &  _b,
const Point2d &  _c,
const Point2d &  _p,
double &  _u,
double &  _v 
)

Check if a 2d point lies inside the triangle defined by three other points.

Parameters
_aThe first triangle vertex.
_bThe second triangle vertex.
_cThe third triangle vertex.
_pThe query point.
_uThe barycentric coordinate factor for _b.
_vThe barycentric coordinate factor for _c.
Returns
True if _p is inside triangle _a_b_c, or false otherwise.

◆ SRand()

void SRand ( const unsigned long  _seed)

Use seedval as the seed.

◆ TriangleHeight()

double TriangleHeight ( const Point3d &  _a,
const Point3d &  _b,
const Point3d &  _c 
)

Determine height of triangle defined by three points.

Parameters
_aThe first triangle vertex.
_bThe second triangle vertex.
_cThe third triangle vertex.
Returns
The height of the triangle.