Functions

/home/hauberg/Dokumenter/Capture/humim-tracker-0.1/src/auxil.h File Reference

#include <string>
#include <vector>
#include <iostream>
#include "math_types.h"

Go to the source code of this file.

Functions

const std::string path_sep ("/")
std::string fullfile (const std::string &dir, const std::string &filename)
std::string fullfile (const std::string &dir1, const std::string &dir2, const std::string &filename)
template<class T >
int find_max_idx (const std::vector< T > &vec)
template<class T >
find_max (const std::vector< T > &vec)
double mod_2pi (const double dx)
double mod_pi (const double dx)
template<class T >
square (const T &a)
template<class T >
double norm2 (const T &a)
template<class T >
double norm (const T &a)
template<class T >
sign (const T &a)
template<class T >
force_in_range (const T &val, const T &min_val, const T &max_val)
vector3 project_point_on_line (const vector3 &p, const vector3 &l1, const vector3 &l2)
vector3 jet (const double x)
vector3 hot (const double x)
double bessi0 (double x)

Function Documentation

double bessi0 ( double  x  ) 

Compute the Modified Bessel function of order 0.

Parameters:
[in] x A real number.
Returns:
The function value of the modified Bessel function of order 0.
template<class T >
T find_max ( const std::vector< T > &  vec  )  [inline]

Find the maximal value of a std::vector.

Parameters:
[in] vec A std::vector of comparable elements.
Returns:
The largest value.
template<class T >
int find_max_idx ( const std::vector< T > &  vec  )  [inline]

Find the maximal entry of a std::vector.

Parameters:
[in] vec A std::vector of comparable elements.
Returns:
The index of the value with the largest value.
template<class T >
T force_in_range ( const T &  val,
const T &  min_val,
const T &  max_val 
) [inline]

Force a real number into an interval.

Parameters:
[in] val Any real number.
[in] min_val The smallest value in the interval.
[in] max_val The largest value in the interval.
Returns:
The number nearest to val the is larger or equal to min_val and smaller or equal to max_val.
std::string fullfile ( const std::string dir,
const std::string filename 
) [inline]

Create a valid file name from the name of the file and the name of the directory containing the file. The function simply concatenates the arguments, while putting a platform specific path seperator between them.

Parameters:
[in] dir The name of a directory.
[in] filename The name of a file.
Returns:
A string containing the directory followed by a path seperator followed by the name of the file.
std::string fullfile ( const std::string dir1,
const std::string dir2,
const std::string filename 
) [inline]

Create a valid file name from the name of the file and the name of the directory containing the file. The function simply concatenates the arguments, while putting a platform specific path seperator between them.

Parameters:
[in] dir1 The name of a directory.
[in] dir2 The name of a directory.
[in] filename The name of a file.
Returns:
A string containing the first directory followed by a path seperator followed the second directory followed by a path seperator and the name of the file.
vector3 hot ( const double  x  ) 

The Hot colour map ranging form black to white.

Parameters:
[in] x A real number between 0 and 1.
Returns:
A 3-vector containing RGB values corresponding to the input.
vector3 jet ( const double  x  ) 

The Jet colour map ranging form blue to red.

Parameters:
[in] x A real number between 0 and 1.
Returns:
A 3-vector containing RGB values corresponding to the input.
double mod_2pi ( const double  dx  )  [inline]

Compute the value of a number modulo two pi.

Parameters:
[in] dx Any number.
Returns:
The input modulo two pi.
double mod_pi ( const double  dx  )  [inline]

Compute the value of a number modulo pi.

Parameters:
[in] dx Any number.
Returns:
The input modulo pi.
template<class T >
double norm ( const T &  a  )  [inline]

Compute the two-norm of a vector.

Parameters:
[in] a A vector.
Returns:
The norm of the input.
template<class T >
double norm2 ( const T &  a  )  [inline]

Compute the square two-norm of a vector.

Parameters:
[in] a A vector.
Returns:
The dot product of the vector with itself (i.e. the square of its norm).
const std::string path_sep ( "/"   ) 

Path seperator on various platforms. On Microsoft Windoes it is \, while it is / on other platforms. This is helpful when doing file IO in a platform independent manor.

vector3 project_point_on_line ( const vector3 p,
const vector3 l1,
const vector3 l2 
) [inline]

Project a 3D point onto a 3D line.

Parameters:
[in] p The 3D point to be projected onto a line.
[in] l1 One point on the line.
[in] l2 Another point on the line (different from l1)
Returns:
The projection of p into the line spanned by l1 and l2.
template<class T >
T sign ( const T &  a  )  [inline]

Compute the sign of a number.

Parameters:
[in] a Any number.
Returns:
If a is negative return -1, +1 or a is positive and 0 if a is 0.
template<class T >
T square ( const T &  a  )  [inline]

Compute the square of a number.

Parameters:
[in] a A number.
Returns:
The number multiplied by itself.