Momentum
A library for solving nonlinear optimization problems related to human body kinematics
Loading...
Searching...
No Matches
utility.h File Reference
#include <momentum/math/constants.h>
#include <momentum/math/types.h>
#include <gsl/gsl>

Go to the source code of this file.

Namespaces

namespace  momentum

Functions

bool momentum::IsNanNoOpt (float f)
 NaN check function that isn't optimized away by fastmath.
Math Utilities
ParameterSet momentum::allParams ()
 Creates a ParameterSet with all parameters set to active.
template<class T>
T momentum::sqr (const T &x)
 Computes the square of a value.
template<typename T = float>
bool momentum::isApprox (T l, T r, T eps=Eps< T >(1e-4, 1e-6)) noexcept
 Determines if two values are approximately equal within a given tolerance.
Matrix Utilities
template<typename T>
MatrixX< T > momentum::pseudoInverse (const MatrixX< T > &mat)
 Calculates the pseudo-inverse of a matrix.
template<typename T>
MatrixX< T > momentum::pseudoInverse (const SparseMatrix< T > &mat)
 Calculates the pseudo-inverse of a sparse matrix.

Geometry Utilities

enum class  momentum::EulerConvention { momentum::Intrinsic , momentum::Extrinsic }
 The Euler angles convention. More...
template<typename T>
Quaternion< T > momentum::quaternionExpMap (const Vector3< T > &v)
 Computes the exponential map from a rotation vector (axis-angle in R^3) to a quaternion.
template<typename T>
Vector3< T > momentum::quaternionLogMap (const Quaternion< T > &q)
 Computes the logarithmic map from a quaternion to a rotation vector (axis-angle in R^3).
template<typename T>
Eigen::Matrix< T, 3, 4 > momentum::quaternionLogMapDerivative (const Quaternion< T > &q)
 Computes the derivative of the logarithmic map with respect to quaternion components.
template<typename T>
Vector3< T > momentum::rotationMatrixToEuler (const Matrix3< T > &m, int axis0, int axis1, int axis2, EulerConvention convention)
 Converts rotation matrix to Euler angles.
template<typename T>
Vector3< T > momentum::rotationMatrixToEulerXYZ (const Matrix3< T > &m, EulerConvention convention)
 An optimized version of rotationMatrixToEuler(m, 0, 1, 2, convention) or rotationMatrixToEuler(m, 2, 1, 0, convention).reverse().
template<typename T>
Vector3< T > momentum::rotationMatrixToEulerZYX (const Matrix3< T > &m, EulerConvention convention)
 An optimized version of rotationMatrixToEuler(m, 2, 1, 0, convention) or rotationMatrixToEuler(m, 0, 1, 2, convention).reverse().
template<typename T>
Vector2< T > momentum::rotationMatrixToTwoAxisEuler (const Matrix3< T > &m, int axis0, int axis1)
 Fits a two-axis Euler rotation to a rotation matrix.
template<typename T>
T momentum::rotationMatrixToOneAxisEuler (const Matrix3< T > &m, int axis0)
 Fits a single-axis Euler rotation to a rotation matrix.
template<typename T>
Quaternion< T > momentum::eulerToQuaternion (const Vector3< T > &angles, int axis0, int axis1, int axis2, EulerConvention convention)
 Converts Euler angles to quaternion.
template<typename T>
Matrix3< T > momentum::eulerToRotationMatrix (const Vector3< T > &angles, int axis0, int axis1, int axis2, EulerConvention convention)
 Converts Euler angles to rotation matrix.
template<typename T>
Matrix3< T > momentum::eulerXYZToRotationMatrix (const Vector3< T > &angles, EulerConvention convention)
 An optimized version of eulerToRotationMatrix(angles, 0, 1, 2, convention) or eulerToRotationMatrix(angles.reverse(), 2, 1, 0, convention).
template<typename T>
Matrix3< T > momentum::eulerZYXToRotationMatrix (const Vector3< T > &angles, EulerConvention convention)
 An optimized version of eulerToRotationMatrix(angles, 2, 1, 0, convention) or eulerToRotationMatrix(angles.reverse(), 0, 1, 2, convention).
template<typename T>
Vector3< T > momentum::quaternionToEuler (const Quaternion< T > &q)
 Converts a quaternion to Euler angles using the Extrinsic XYZ convention.
Quaternionf momentum::quaternionAverage (momentum::span< const Quaternionf > q, momentum::span< const float > w={})
 Computes the weighted average of multiple quaternions.
template<typename T>
std::tuple< bool, T, Eigen::Vector2< T > > momentum::closestPointsOnSegments (const Eigen::Vector3< T > &o1, const Eigen::Vector3< T > &d1, const Eigen::Vector3< T > &o2, const Eigen::Vector3< T > &d2, T maxDist=std::numeric_limits< T >::max())
 Returns the closest points on two line segments where the line segments are represented in origin and direction.
template<typename T>
Eigen::Matrix< T, 3, 3 > momentum::crossProductMatrix (const Eigen::Vector3< T > &v)
 Creates a skew-symmetric matrix for computing cross products.