MIRA
Classes | Typedefs | Functions
Math Module


For detailed information see Math. More...

Collaboration diagram for Math Module:

Classes

class  SignedDegree< T >
 Signed angle that is represented using degrees. More...
 
class  Degree< T >
 Unsigned angle that is represented using degrees. More...
 
class  SignedRadian< T >
 Signed angle that is represented using radians. More...
 
class  Radian< T >
 Unsigned angle that is represented using radians. More...
 
class  SignedAngle< T >
 Signed angle that is represented using radians. More...
 
class  Angle< T >
 Unsigned angle that is represented using radians. More...
 
class  CRSplineInterpolator
 1D cubic Hermite spline interpolator. More...
 
class  IntervalFilter
 Concept and base class for all Interpolators and Filters. More...
 
class  LinearInterpolator
 1D linear interpolator. More...
 
class  LinearInterpolatorNoExtrapolation
 1D linear interpolator. More...
 
class  LinearInterpolatorNearestNeighbourExtrapolator
 1D linear interpolator. More...
 
class  LinearInterpolatorExtrapolationLimit
 1D linear interpolator. More...
 
class  NearestNeighborInterpolator
 1D nearest neighbor interpolator. More...
 
class  NormalRandomDistribution< D, T >
 Random distribution for drawing samples from univariate or multivariate normal distributions. More...
 
class  NormalRandomGenerator< D, T >
 Random generator for drawing samples from univariate or multivariate normal distributions. More...
 
struct  TPower< base, exponent >
 Computes the power base^exponent at compile time. More...
 
class  RandomGeneratorSingleton
 Singleton class for generating random numbers. More...
 
class  RandomGenerator< Distribution, Engine >
 Template class to easily generate random generators using the boost::random distributions and generators. More...
 
class  SchmittTriggerHysteresis< T >
 Class realizing a Schmitt trigger. More...
 
class  UniformRandomGenerator< T >
 A random generator that samples random numbers within the interval that is passed to the constructor. More...
 

Typedefs

typedef SignedDegree< int > SignedDegreei
 Integer precision signed angle. More...
 
typedef SignedDegree< float > SignedDegreef
 Float precision signed angle. More...
 
typedef SignedDegree< double > SignedDegreed
 Double precision signed angle. More...
 
typedef Degree< int > Degreei
 Integer precision angle. More...
 
typedef Degree< float > Degreef
 Float precision angle. More...
 
typedef Degree< double > Degreed
 Double precision angle. More...
 
typedef SignedRadian< float > SignedRadianf
 Float precision signed angle. More...
 
typedef SignedRadian< double > SignedRadiand
 Double precision signed angle. More...
 
typedef Radian< float > Radianf
 Float precision angle. More...
 
typedef Radian< double > Radiand
 Double precision angle. More...
 
typedef SignedAngle< float > SignedAnglef
 Float precision signed angle. More...
 
typedef SignedAngle< double > SignedAngled
 Double precision signed angle. More...
 
typedef Angle< float > Anglef
 Float precision angle. More...
 
typedef Angle< double > Angled
 Double precision angle. More...
 

Functions

template<typename T >
smallestAngleDifference (const T &a, const T &b)
 Returns the signed difference angle between the specified angles (in radian) that has the smallest absolute value. More...
 
template<typename T >
bool isInAngleInterval (T value, T min, T max)
 Returns true, if the given angle (in radian) is in the given interval [min,max]. More...
 
template<typename T >
Getter< T > rad2degGetter (const T &cref)
 Create a getter for serializing radians as degrees. More...
 
template<typename T >
Setter< T > deg2radSetter (T &ref)
 Create setter for deserializing radians from degrees. See rad2degGetter. More...
 
template<typename T >
Setter< T > deg2radSetter (T &ref, Deg2RadNonNegativeType)
 Create a setter for deserializing radians from degrees. More...
 
template<typename T >
Accessor< Getter< T >, Setter< T > > radAsDegAccessor (T &ref)
 Create an accessor consisting of getter + setter for serializing radians as degrees. More...
 
template<typename T >
Accessor< Getter< T >, Setter< T > > radAsDegAccessor (T &ref, Deg2RadNonNegativeType)
 Create a complete accessor consisting of getter + setter for serializing radians as degrees. More...
 
template<typename Derived >
TEigenFormat< Derived > format (Eigen::MatrixBase< Derived > &matrix, Eigen::IOFormat format=EigenFormat::matlab())
 Function for formatting an Eigen matrix using a special format. More...
 
template<typename T , typename U >
bool isApprox (const T &a, const T &b, const U &tol)
 Returns true, if the value a has approximately the same value as b. More...
 
template<typename T , typename S >
lerp (const T &a, const T &b, S alpha)
 Linear interpolation of different types like scalars, angles and rotations, vectors, etc. More...
 
template<typename T >
modulo (T x, T y)
 Computes x modulo y, i.e. More...
 
float normcdf (float x, float mu=0.0, float sigma=1.0)
 Computes the normal cumulative distribution function at the value x using the specified mean mu and standard deviation sigma. More...
 
template<int exponent, typename T >
pow (T base)
 Computes the power of 'base' with a constant integral exponent. More...
 
template<typename T >
pow2 (T base)
 Computes base^2. More...
 
template<typename T >
pow3 (T base)
 Computes base^3. More...
 
template<typename T >
const T & saturate (const T &value, const T &minValue, const T &maxValue)
 Saturate a value by limiting it to a certain interval. More...
 
template<typename T >
truncate (T value, uint32 decimals)
 Truncates a floating point value to a given number of decimals. More...
 
template<typename T >
Eigen::Quaternion< T > quaternionFromYawPitchRoll (T yaw, T pitch, T roll)
 Converts yaw, pitch and roll angles to a quaternion. More...
 
template<typename T >
void quaternionCovFromYawPitchRollCov (const Eigen::Matrix< T, 6, 6 > &eulerCovariance, float yaw, float pitch, float roll, Eigen::Quaternion< T > &oOrientation, Eigen::Matrix< T, 7, 7 > &oCovariance)
 Converts 6x6 dimensional covariance matrix (3D + yaw, pitch and roll) angles to a 7x7 dimensional quaternion covariance matrix (3D + Quaternion) Our convention for the order of rotations is as follows:

  1. yaw around the Z-Axis (pointing upwards)
  2. pitch around the Y-Axis (pointing left)
  3. roll around the X-Axis (pointing forward)
More...
 
template<typename T >
Eigen::Matrix< T, 7, 7 > quaternionCovFromYawPitchRollCov (const Eigen::Matrix< T, 6, 6 > &eulerCovariance, float yaw, float pitch, float roll)
 Converts 6x6 dimensional covariance matrix (3D + yaw, pitch and roll) angles to a 7x7 dimensional quaternion covariance matrix (3D + Quaternion) Our convention for the order of rotations is as follows:

  1. yaw around the Z-Axis (pointing upwards)
  2. pitch around the Y-Axis (pointing left)
  3. roll around the X-Axis (pointing forward)
More...
 
template<typename T >
boost::tuples::tuple< T, T, T > quaternionToYawPitchRoll (const Eigen::Quaternion< T > &q)
 Converts a quaternion back to yaw, pitch, roll angles. More...
 
template<typename T >
Eigen::Matrix< T, 6, 6 > quaternionCovToYawPitchRollCov (const Eigen::Matrix< T, 7, 7 > &covariance, const Eigen::Quaternion< T > &q)
 Converts a 7x7 dimensional quaternion covariance (3D + Quaternion) back to a 6x6 dimensional euler covariance (3D + Yaw, Pitch, Roll). More...
 
template<typename T >
Eigen::Matrix< T, 3, 3 > matrixFromYawPitchRoll (T yaw, T pitch, T roll)
 Converts yaw, pitch and roll angles to a rotation matrix. More...
 
template<typename T >
Eigen::Matrix< T, 3, 3 > matrixFromYawPitchRoll (const boost::tuples::tuple< T, T, T > &ypr)
 Same as the above method, that takes the yaw,pitch,roll angles as 3-tuple. More...
 
template<typename T >
boost::tuples::tuple< T, T, T > matrixToYawPitchRoll (const Eigen::Matrix< T, 3, 3 > &r)
 Converts a rotation matrix back to yaw, pitch, roll angles. More...
 
template<typename T >
void derivMatricesFromYawPitchRoll (T yaw, T pitch, T roll, Eigen::Matrix< T, 3, 3 > &oR_dyaw, Eigen::Matrix< T, 3, 3 > &oR_dpitch, Eigen::Matrix< T, 3, 3 > &oR_droll)
 Returns the 3 derivates of the above rotation matrix, i.e. More...
 

Detailed Description


For detailed information see Math.

Typedef Documentation

◆ SignedDegreei

Integer precision signed angle.

See also
SignedDegree

◆ SignedDegreef

typedef SignedDegree<float> SignedDegreef

Float precision signed angle.

See also
SignedDegree

◆ SignedDegreed

typedef SignedDegree<double> SignedDegreed

Double precision signed angle.

See also
SignedDegree

◆ Degreei

typedef Degree<int> Degreei

Integer precision angle.

See also
Degree

◆ Degreef

typedef Degree<float> Degreef

Float precision angle.

See also
Degree

◆ Degreed

typedef Degree<double> Degreed

Double precision angle.

See also
Degree

◆ SignedRadianf

typedef SignedRadian<float> SignedRadianf

Float precision signed angle.

See also
SignedRadian

◆ SignedRadiand

typedef SignedRadian<double> SignedRadiand

Double precision signed angle.

See also
SignedRadian

◆ Radianf

typedef Radian<float> Radianf

Float precision angle.

See also
Radian

◆ Radiand

typedef Radian<double> Radiand

Double precision angle.

See also
Radian

◆ SignedAnglef

typedef SignedAngle<float> SignedAnglef

Float precision signed angle.

See also
SignedAngle

◆ SignedAngled

typedef SignedAngle<double> SignedAngled

Double precision signed angle.

See also
SignedAngle

◆ Anglef

typedef Angle<float> Anglef

Float precision angle.

See also
Angle

◆ Angled

typedef Angle<double> Angled

Double precision angle.

See also
Angle

Function Documentation

◆ smallestAngleDifference()

T mira::smallestAngleDifference ( const T &  a,
const T &  b 
)
inline

Returns the signed difference angle between the specified angles (in radian) that has the smallest absolute value.

◆ isInAngleInterval()

bool mira::isInAngleInterval ( value,
min,
max 
)
inline

Returns true, if the given angle (in radian) is in the given interval [min,max].

◆ rad2degGetter()

Getter<T> mira::rad2degGetter ( const T &  cref)

Create a getter for serializing radians as degrees.

Usage:

r.property("Phi",
"phi internally stored in radians, serialized in degrees",
90.f);

rad2degGetter/deg2radSetter must be used together for symmetric serialization/deserialization

◆ deg2radSetter() [1/2]

Setter<T> mira::deg2radSetter ( T &  ref)

Create setter for deserializing radians from degrees. See rad2degGetter.

◆ deg2radSetter() [2/2]

Setter<T> mira::deg2radSetter ( T &  ref,
Deg2RadNonNegativeType   
)

Create a setter for deserializing radians from degrees.

This setter variant throws XInvalidParameter when trying to set a negative value.

Usage:

r.property("Phi",
"phi internally stored in radians, serialized in degrees",
90.f);

◆ radAsDegAccessor() [1/2]

Accessor<Getter<T>, Setter<T> > mira::radAsDegAccessor ( T &  ref)

Create an accessor consisting of getter + setter for serializing radians as degrees.

Usage:

auto acc = radAsDegAccessor(mPhi);
r.property("Phi", acc, "phi internally stored in radians, serialized in degrees", 90.f);

◆ radAsDegAccessor() [2/2]

Accessor<Getter<T>, Setter<T> > mira::radAsDegAccessor ( T &  ref,
Deg2RadNonNegativeType   
)

Create a complete accessor consisting of getter + setter for serializing radians as degrees.

The setter from this variant throws XInvalidParameter when trying to set a negative value

Usage:

r.property("Phi", acc, "phi internally stored in radians, serialized in degrees", 90.f);

◆ format()

TEigenFormat<Derived> mira::format ( Eigen::MatrixBase< Derived > &  matrix,
Eigen::IOFormat  format = EigenFormat::matlab() 
)
inline

Function for formatting an Eigen matrix using a special format.

This function can be used for writing and even reading a matrix to or from a stream in the given format.

Predefined formats are:

Usage:

Matrix... m
// read a matrix from the stream in Matlab format:
// write a matrix to the given stream in Matlab format using
// a precision of 9 significant digits.
Parameters
matrixThe matrix that gets serialized.
formatThe format to use.

◆ isApprox()

bool mira::isApprox ( const T &  a,
const T &  b,
const U &  tol 
)
inline

Returns true, if the value a has approximately the same value as b.

The tolerance is given as third parameter. More precisely, the method returns true, if b is in the interval [a-tol,a+tol).

◆ lerp()

T mira::lerp ( const T &  a,
const T &  b,
alpha 
)
inline

Linear interpolation of different types like scalars, angles and rotations, vectors, etc.

Rotations are interpolated via spherical linear interpolation (slerp).

The parameter alpha can vary between 0 and 1, where alpha=0 will return a and alpha=1 will return b. For values between 0 and 1 an interpolated value is returned. For some types alpha is allowed to be <0 or >1. In this case the method will extrapolate.

◆ modulo()

T mira::modulo ( x,
y 
)
inline

Computes x modulo y, i.e.

the remainder of the division operation x/y. This function is specialized for integral and floating point types. For integral types, the built in % operator is used. For floating point types the std::fmod() method is used.

◆ normcdf()

float mira::normcdf ( float  x,
float  mu = 0.0,
float  sigma = 1.0 
)
inline

Computes the normal cumulative distribution function at the value x using the specified mean mu and standard deviation sigma.

Note: sigma must be > 0.

◆ pow()

T mira::pow ( base)
inline

Computes the power of 'base' with a constant integral exponent.

Instead of:

float result = 0.4f*0.4f*0.4f*0.4f*0.4f*0.4f*0.4f*0.4f*0.4f*0.4f;

you can now write:

float result = pow<10>(0.4f);

which is much better to read and produces exactly the same code. Hence, the second variant is exactly as fast as the first one.

◆ pow2()

T mira::pow2 ( base)
inline

Computes base^2.

◆ pow3()

T mira::pow3 ( base)
inline

Computes base^3.

◆ saturate()

const T& mira::saturate ( const T &  value,
const T &  minValue,
const T &  maxValue 
)
inline

Saturate a value by limiting it to a certain interval.

Parameters
[in]valueThe value to saturate
[in]minValueThe minimum value of the interval
[in]maxValueThe maximum value of the interval
Returns
The value clamped to the interval

◆ truncate()

T mira::truncate ( value,
uint32  decimals 
)

Truncates a floating point value to a given number of decimals.

truncate(3.141f,1) will give 3.1f
Parameters
valueValue to truncate
decimalsDecimals that should be kept
Returns
Truncated value

◆ quaternionFromYawPitchRoll()

Eigen::Quaternion<T> mira::quaternionFromYawPitchRoll ( yaw,
pitch,
roll 
)
inline

Converts yaw, pitch and roll angles to a quaternion.

Our convention for the order of rotations is as follows:

  1. yaw around the Z-Axis (pointing upwards)
  2. pitch around the Y-Axis (pointing left)
  3. roll around the X-Axis (pointing forward)
Parameters
[in]yawThe yaw angle
[in]pitchThe pitch angle
[in]rollThe roll angle
Returns
The yaw, pitch and roll angles as a quaternion

◆ quaternionCovFromYawPitchRollCov() [1/2]

void mira::quaternionCovFromYawPitchRollCov ( const Eigen::Matrix< T, 6, 6 > &  eulerCovariance,
float  yaw,
float  pitch,
float  roll,
Eigen::Quaternion< T > &  oOrientation,
Eigen::Matrix< T, 7, 7 > &  oCovariance 
)
inline

Converts 6x6 dimensional covariance matrix (3D + yaw, pitch and roll) angles to a 7x7 dimensional quaternion covariance matrix (3D + Quaternion) Our convention for the order of rotations is as follows:

  1. yaw around the Z-Axis (pointing upwards)
  2. pitch around the Y-Axis (pointing left)
  3. roll around the X-Axis (pointing forward)

Our convention for the order of the quaternion is

  1. qw
  2. qx
  3. qy
  4. qz
Parameters
[in]eulerCovarianceThe 3D+Yaw,Pitch,Roll covaraiance matrix
[in]yawThe covariance matrix's orientation
[in]pitchThe covariance matrix's orientation
[in]rollThe covariance matrix's orientation
[out]oOrientationThe computed quaternion from euler angles
[out]oCovarianceThe computed 7x7 covariance matrix in quaternion space

◆ quaternionCovFromYawPitchRollCov() [2/2]

Eigen::Matrix<T,7,7> mira::quaternionCovFromYawPitchRollCov ( const Eigen::Matrix< T, 6, 6 > &  eulerCovariance,
float  yaw,
float  pitch,
float  roll 
)
inline

Converts 6x6 dimensional covariance matrix (3D + yaw, pitch and roll) angles to a 7x7 dimensional quaternion covariance matrix (3D + Quaternion) Our convention for the order of rotations is as follows:

  1. yaw around the Z-Axis (pointing upwards)
  2. pitch around the Y-Axis (pointing left)
  3. roll around the X-Axis (pointing forward)

Our convention for the order of the quaternion is

  1. qw
  2. qx
  3. qy
  4. qz
Parameters
[in]eulerCovarianceThe 3D+Yaw,Pitch,Roll covaraiance matrix
[in]yawThe covariance matrix's orientation
[in]pitchThe covariance matrix's orientation
[in]rollThe covariance matrix's orientation
Returns
The 7x7 dimensional covariance matrix in quaternion space.

◆ quaternionToYawPitchRoll()

boost::tuples::tuple<T,T,T> mira::quaternionToYawPitchRoll ( const Eigen::Quaternion< T > &  q)
inline

Converts a quaternion back to yaw, pitch, roll angles.

This operation is the opposite of quaternionFromYawPitchRoll().

Please note: If a quaternion was created using quaternionFromYawPitchRoll() this method may return yaw,pitch,roll angles that may differ from the values used in the quaternionFromYawPitchRoll() call. The reason is that a single rotation can be described by different combinations of yaw, pitch and roll angles.

For details see quaternionFromYawPitchRoll().

Parameters
[in]qThe quaternion with yaw, pitch and roll angles.
Returns
Returns the yaw, pitch and roll angle as 3-tuple.

◆ quaternionCovToYawPitchRollCov()

Eigen::Matrix<T,6,6> mira::quaternionCovToYawPitchRollCov ( const Eigen::Matrix< T, 7, 7 > &  covariance,
const Eigen::Quaternion< T > &  q 
)
inline

Converts a 7x7 dimensional quaternion covariance (3D + Quaternion) back to a 6x6 dimensional euler covariance (3D + Yaw, Pitch, Roll).

This operation is the opposite of quaternionCovFromYawPitchRollCov().

Parameters
[in]covarianceThe 3D+Quaternion covariance matrix
[in]qThe covariance matrix's orientation
Returns
Returns the 6x6 dimensional covariance matrix (x,y,z,yaw,pitch,roll)

◆ matrixFromYawPitchRoll() [1/2]

Eigen::Matrix<T,3,3> mira::matrixFromYawPitchRoll ( yaw,
pitch,
roll 
)
inline

Converts yaw, pitch and roll angles to a rotation matrix.

Our convention for the order of rotations is as follows:

  1. yaw around the Z-Axis (pointing upwards)
  2. pitch around the Y-Axis (pointing left)
  3. roll around the X-Axis (pointing forward)
Parameters
[in]yawThe yaw angle
[in]pitchThe pitch angle
[in]rollThe roll angle
Returns
A rotation matrix for yaw, pitch and roll.

◆ matrixFromYawPitchRoll() [2/2]

Eigen::Matrix<T,3,3> mira::matrixFromYawPitchRoll ( const boost::tuples::tuple< T, T, T > &  ypr)
inline

Same as the above method, that takes the yaw,pitch,roll angles as 3-tuple.

◆ matrixToYawPitchRoll()

boost::tuples::tuple<T,T,T> mira::matrixToYawPitchRoll ( const Eigen::Matrix< T, 3, 3 > &  r)
inline

Converts a rotation matrix back to yaw, pitch, roll angles.

This is operation is the opposite of matrixFromYawPitchRoll().

Our convention for the order of rotations is as follows:

  1. yaw around the Z-Axis (pointing upwards)
  2. pitch around the Y-Axis (pointing left)
  3. roll around the X-Axis (pointing forward)
Parameters
[in]rThe rotation matrix.
Returns
Returns the yaw, pitch and roll angle as 3-tuple.

◆ derivMatricesFromYawPitchRoll()

void mira::derivMatricesFromYawPitchRoll ( yaw,
pitch,
roll,
Eigen::Matrix< T, 3, 3 > &  oR_dyaw,
Eigen::Matrix< T, 3, 3 > &  oR_dpitch,
Eigen::Matrix< T, 3, 3 > &  oR_droll 
)
inline

Returns the 3 derivates of the above rotation matrix, i.e.

3 matrices that are derived to yaw, pitch and roll respectively.

Our convention for the order of rotations is as follows:

  1. yaw around the Z-Axis (pointing upwards)
  2. pitch around the Y-Axis (pointing left)
  3. roll around the X-Axis (pointing forward)
Parameters
[in]yawThe yaw angle
[in]pitchThe pitch angle
[in]rollThe roll angle
[out]oR_dyawThe matrixe derivated to yaw
[out]oR_dpitchThe matrixe derivated to pitch
[out]oR_drollThe matrixe derivated to roll