supereight
Functions
se::math Namespace Reference

Functions

template<typename T >
constexpr bool is_power_of_two (T)
 
template<>
constexpr bool is_power_of_two< unsigned > (const unsigned x)
 
constexpr int log2_const (int n)
 
static unsigned power_two_up (const float x)
 
template<typename T >
static T fracf (const T &v)
 
template<typename T >
static T floorf (const T &v)
 
template<typename T >
static T fabs (const T &v)
 
template<typename Scalar >
static constexpr Scalar sq (Scalar a)
 
template<typename Scalar >
static constexpr Scalar cu (Scalar a)
 
template<typename Scalar >
static bool in (const Scalar v, const Scalar a, const Scalar b)
 
static Eigen::Vector3f to_translation (const Eigen::Matrix4f &T)
 
static Eigen::Matrix3f to_rotation (const Eigen::Matrix4f &T)
 
static Eigen::Matrix4f to_transformation (const Eigen::Vector3f &t)
 
static Eigen::Matrix4f to_transformation (const Eigen::Matrix3f &R)
 
static Eigen::Matrix4f to_transformation (const Eigen::Matrix3f &R, const Eigen::Vector3f &t)
 
static Eigen::Vector3f to_inverse_translation (const Eigen::Matrix4f &T)
 
static Eigen::Matrix3f to_inverse_rotation (const Eigen::Matrix4f &T)
 
static Eigen::Matrix4f to_inverse_transformation (const Eigen::Matrix4f &T)
 
template<typename T >
static std::enable_if< std::is_arithmetic< T >::value, T >::type clamp (const T &f, const T &a, const T &b)
 
static void clamp (Eigen::Ref< Eigen::VectorXf > res, const Eigen::Ref< const Eigen::VectorXf > a, const Eigen::Ref< Eigen::VectorXf > b)
 
template<typename R , typename A , typename B >
static void clamp (Eigen::MatrixBase< R > &res, const Eigen::MatrixBase< A > &a, const Eigen::MatrixBase< B > &b)
 
static Eigen::Vector3f plane_normal (const Eigen::Vector3f &p1, const Eigen::Vector3f &p2, const Eigen::Vector3f &p3)
 Compute the normal vector of a plane defined by 3 points. More...
 
template<typename T >
static T median (std::vector< T > &data)
 Compute the median of the data in the vector. More...
 
template<typename T >
static T almost_median (std::vector< T > &data)
 Compute the median of the data in the vector. More...
 
template<typename T >
static T median (const std::vector< T > &data)
 Same as se::math::median() but the order of the original vector is retain. More...
 
static Eigen::Matrix3f hat (const Eigen::Vector3f &omega)
 hat-operator More...
 
static Eigen::Matrix3f exp_and_theta (const Eigen::Vector3f &omega, float &theta)
 
static Eigen::Matrix4f exp (const Eigen::Matrix< float, 6, 1 > &a)
 Group exponential. More...
 

Function Documentation

◆ is_power_of_two()

template<typename T >
constexpr bool se::math::is_power_of_two ( )

◆ is_power_of_two< unsigned >()

template<>
constexpr bool se::math::is_power_of_two< unsigned > ( const unsigned  x)

◆ log2_const()

constexpr int se::math::log2_const ( int  n)

◆ power_two_up()

static unsigned se::math::power_two_up ( const float  x)
inlinestatic

◆ fracf()

template<typename T >
static T se::math::fracf ( const T &  v)
inlinestatic

◆ floorf()

template<typename T >
static T se::math::floorf ( const T &  v)
inlinestatic

◆ fabs()

template<typename T >
static T se::math::fabs ( const T &  v)
inlinestatic

◆ sq()

template<typename Scalar >
static constexpr Scalar se::math::sq ( Scalar  a)
inlinestatic

◆ cu()

template<typename Scalar >
static constexpr Scalar se::math::cu ( Scalar  a)
inlinestatic

◆ in()

template<typename Scalar >
static bool se::math::in ( const Scalar  v,
const Scalar  a,
const Scalar  b 
)
inlinestatic

◆ to_translation()

static Eigen::Vector3f se::math::to_translation ( const Eigen::Matrix4f &  T)
inlinestatic

◆ to_rotation()

static Eigen::Matrix3f se::math::to_rotation ( const Eigen::Matrix4f &  T)
inlinestatic

◆ to_transformation() [1/3]

static Eigen::Matrix4f se::math::to_transformation ( const Eigen::Vector3f &  t)
inlinestatic

◆ to_transformation() [2/3]

static Eigen::Matrix4f se::math::to_transformation ( const Eigen::Matrix3f &  R)
inlinestatic

◆ to_transformation() [3/3]

static Eigen::Matrix4f se::math::to_transformation ( const Eigen::Matrix3f &  R,
const Eigen::Vector3f &  t 
)
inlinestatic

◆ to_inverse_translation()

static Eigen::Vector3f se::math::to_inverse_translation ( const Eigen::Matrix4f &  T)
inlinestatic

◆ to_inverse_rotation()

static Eigen::Matrix3f se::math::to_inverse_rotation ( const Eigen::Matrix4f &  T)
inlinestatic

◆ to_inverse_transformation()

static Eigen::Matrix4f se::math::to_inverse_transformation ( const Eigen::Matrix4f &  T)
inlinestatic

◆ clamp() [1/3]

template<typename T >
static std::enable_if<std::is_arithmetic<T>::value, T>::type se::math::clamp ( const T &  f,
const T &  a,
const T &  b 
)
inlinestatic

◆ clamp() [2/3]

static void se::math::clamp ( Eigen::Ref< Eigen::VectorXf >  res,
const Eigen::Ref< const Eigen::VectorXf >  a,
const Eigen::Ref< Eigen::VectorXf >  b 
)
inlinestatic

◆ clamp() [3/3]

template<typename R , typename A , typename B >
static void se::math::clamp ( Eigen::MatrixBase< R > &  res,
const Eigen::MatrixBase< A > &  a,
const Eigen::MatrixBase< B > &  b 
)
inlinestatic

◆ plane_normal()

static Eigen::Vector3f se::math::plane_normal ( const Eigen::Vector3f &  p1,
const Eigen::Vector3f &  p2,
const Eigen::Vector3f &  p3 
)
static

Compute the normal vector of a plane defined by 3 points.

The direction of the normal depends on the order of the points.

◆ median() [1/2]

template<typename T >
static T se::math::median ( std::vector< T > &  data)
static

Compute the median of the data in the vector.

Parameters
[in,out]dataThe data to compute the median of. The vector will be sorted in-place.
Returns
The median of the data. If input vector is empty, the value returned by the constructor T() is returned. This is typically 0.
Warning
The vector will be sorted inside this function.
Note
Weird things will happen if the vector contains NaNs.

◆ almost_median()

template<typename T >
static T se::math::almost_median ( std::vector< T > &  data)
static

Compute the median of the data in the vector.

If the vector has an even number of elements, the second of the two middle elements will be returned instead of their average. This is done to avoid creating values that don't exist in the original data.

Parameters
[in,out]dataThe data to compute the median of. The vector will be sorted in-place.
Returns
The median of the data. If input vector is empty, the value returned by the constructor T() is returned. This is typically 0.
Warning
The vector will be sorted inside this function.
Note
Weird things will happen if the vector contains NaNs.

◆ median() [2/2]

template<typename T >
static T se::math::median ( const std::vector< T > &  data)
static

Same as se::math::median() but the order of the original vector is retain.

This has a performance impact proportional to the size of the input vector.

◆ hat()

static Eigen::Matrix3f se::math::hat ( const Eigen::Vector3f &  omega)
static

hat-operator

It takes in the 3-vector representation omega (= rotation vector) and returns the corresponding matrix representation of Lie algebra element.

Formally, the hat()-operator of SO(3) is defined as

hat(.): R^3 -> R^{3x3}, hat(omega) = sum_i omega_i * G_i (for i=0,1,2)

with G_i being the ith infinitesimal generator of SO(3).

The corresponding inverse is the vee()-operator, see below.

Parameters
[in]omegarotation vector
Returns
Corresponding matrix representation of Lie algebra element.

◆ exp_and_theta()

static Eigen::Matrix3f se::math::exp_and_theta ( const Eigen::Vector3f &  omega,
float &  theta 
)
static

◆ exp()

static Eigen::Matrix4f se::math::exp ( const Eigen::Matrix< float, 6, 1 > &  a)
static

Group exponential.

This functions takes in an element of tangent space (= twist a) and returns the corresponding element of the group SE(3).

The first three components of a represent the translational part upsilon in the tangent space of SE(3), while the last three components of a represents the rotation vector omega. To be more specific, this function computes expmat(hat(a)) with expmat(.) being the matrix exponential and hat(.) the hat-operator of SE(3), see below.