Momentum
A library for solving nonlinear optimization problems related to human body kinematics
Loading...
Searching...
No Matches
utility.cpp File Reference
#include "momentum/math/utility.h"
#include "momentum/common/checks.h"
#include "momentum/math/constants.h"
#include <Eigen/Eigenvalues>
#include <algorithm>
#include <limits>
#include <type_traits>

Go to the source code of this file.

Namespaces

namespace  momentum

Functions

template MatrixX< float > momentum::pseudoInverse (const MatrixX< float > &mat)
template MatrixX< double > momentum::pseudoInverse (const MatrixX< double > &mat)
template MatrixX< float > momentum::pseudoInverse (const SparseMatrix< float > &mat)
template MatrixX< double > momentum::pseudoInverse (const SparseMatrix< double > &mat)
template Quaternion< float > momentum::quaternionExpMap (const Vector3< float > &v)
template Quaternion< double > momentum::quaternionExpMap (const Vector3< double > &v)
template Vector3< float > momentum::quaternionLogMap (const Quaternion< float > &q)
template Vector3< double > momentum::quaternionLogMap (const Quaternion< double > &q)
template Eigen::Matrix< float, 3, 4 > momentum::quaternionLogMapDerivative (const Quaternion< float > &q)
template Eigen::Matrix< double, 3, 4 > momentum::quaternionLogMapDerivative (const Quaternion< double > &q)
template Vector3< float > momentum::rotationMatrixToEuler (const Matrix3< float > &m, int axis0, int axis1, int axis2, EulerConvention convention)
template Vector3< double > momentum::rotationMatrixToEuler (const Matrix3< double > &m, int axis0, int axis1, int axis2, EulerConvention convention)
template Vector3< float > momentum::rotationMatrixToEulerXYZ (const Matrix3< float > &m, EulerConvention convention)
template Vector3< double > momentum::rotationMatrixToEulerXYZ (const Matrix3< double > &m, EulerConvention convention)
template Vector3< float > momentum::rotationMatrixToEulerZYX (const Matrix3< float > &m, EulerConvention convention)
template Vector3< double > momentum::rotationMatrixToEulerZYX (const Matrix3< double > &m, EulerConvention convention)
template Quaternion< float > momentum::eulerToQuaternion (const Vector3< float > &angles, int axis0, int axis1, int axis2, EulerConvention convention)
template Quaternion< double > momentum::eulerToQuaternion (const Vector3< double > &angles, int axis0, int axis1, int axis2, EulerConvention convention)
template Matrix3< float > momentum::eulerToRotationMatrix (const Vector3< float > &angles, int axis0, int axis1, int axis2, EulerConvention convention)
template Matrix3< double > momentum::eulerToRotationMatrix (const Vector3< double > &angles, int axis0, int axis1, int axis2, EulerConvention convention)
template Matrix3< float > momentum::eulerXYZToRotationMatrix (const Vector3< float > &angles, EulerConvention convention)
template Matrix3< double > momentum::eulerXYZToRotationMatrix (const Vector3< double > &angles, EulerConvention convention)
template Matrix3< float > momentum::eulerZYXToRotationMatrix (const Vector3< float > &angles, EulerConvention convention)
template Matrix3< double > momentum::eulerZYXToRotationMatrix (const Vector3< double > &angles, EulerConvention convention)
template Vector3f momentum::quaternionToEuler (const Quaternionf &q)
template Vector3d momentum::quaternionToEuler (const Quaterniond &q)
template std::tuple< bool, float, Eigen::Vector2< float > > momentum::closestPointsOnSegments< float > (const Eigen::Vector3< float > &o1, const Eigen::Vector3< float > &d1, const Eigen::Vector3< float > &o2, const Eigen::Vector3< float > &d2, const float maxDist)
template std::tuple< bool, double, Eigen::Vector2< double > > momentum::closestPointsOnSegments< double > (const Eigen::Vector3< double > &o1, const Eigen::Vector3< double > &d1, const Eigen::Vector3< double > &o2, const Eigen::Vector3< double > &d2, const double maxDist)
template float momentum::rotationMatrixToOneAxisEuler (const Matrix3< float > &m, int axis0)
template double momentum::rotationMatrixToOneAxisEuler (const Matrix3< double > &m, int axis0)
template Vector2< float > momentum::rotationMatrixToTwoAxisEuler (const Matrix3< float > &m, int axis0, int axis1)
template Vector2< double > momentum::rotationMatrixToTwoAxisEuler (const Matrix3< double > &m, int axis0, int axis1)
Geometry Utilities
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>
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>
T momentum::rotationMatrixToOneAxisEuler (const Matrix3< T > &m, int axis0)
 Fits a single-axis Euler rotation to a rotation matrix.
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.
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.