|
Momentum
A library for solving nonlinear optimization problems related to human body kinematics
|
Lightweight transform with separate rotation, translation, and uniform scaling. More...
#include <transform.h>
Public Member Functions | |
| TransformT () | |
| Creates the identity transform (zero translation, identity rotation, unit scale). | |
| template<typename T2> | |
| TransformT (const TransformT< T2 > &other) | |
| TransformT (const Vector3< T > &translation_in, const Quaternion< T > &rotation_in=Quaternion< T >::Identity(), const T &scale_in=T(1)) | |
| TransformT (Vector3< T > &&translation_in, Quaternion< T > &&rotation_in=Quaternion< T >::Identity(), T &&scale_in=T(1)) | |
| TransformT (const Affine3< T > &other) | |
| TransformT (const Matrix4< T > &other) | |
| TransformT< T > & | operator= (const Affine3< T > &other) |
| TransformT< T > & | operator= (const Matrix4< T > &other) |
| TransformT< T > | operator* (const TransformT< T > &other) const |
| Composes transforms: (*this) * other applies other first, then *this. | |
| Affine3< T > | operator* (const Affine3< T > &other) const |
| Composes with an Affine3. | |
| Vector3< T > | operator* (const Vector3< T > &other) const |
| operator Affine3< T > () const | |
| Affine3< T > | toAffine3 () const |
| Matrix4< T > | toMatrix () const |
| Returns the equivalent 4x4 homogeneous matrix [s*R | t; 0 0 0 1]. | |
| Matrix3< T > | toRotationMatrix () const |
| Returns the rotation as a 3x3 orthogonal matrix (scale not included). | |
| Matrix3< T > | toLinear () const |
| Returns scale * R, the linear part of the transform. | |
| Vector3< T > | getAxisX () const |
| Returns the rotated unit-X axis (i.e. | |
| Vector3< T > | transformPoint (const Vector3< T > &pt) const |
| Applies the full transform to a point: translation + rotation * (scale * pt). | |
| Vector3< T > | rotate (const Vector3< T > &vec) const |
| Applies only the rotation to a direction vector (translation and scale are ignored). | |
| TransformT< T > | inverse () const |
| Returns the inverse transform such that (*this) * inverse() == identity. | |
| template<typename T2> | |
| TransformT< T2 > | cast () const |
| bool | isApprox (const TransformT< T > &other, T tol=Eigen::NumTraits< T >::dummy_precision()) const |
| Approximate equality test using tol as a relative precision. | |
Static Public Member Functions | |
| static TransformT< T > | makeRotation (const Quaternion< T > &rotation_in) |
| Creates a transform with the given rotation, identity translation, and unit scale. | |
| static TransformT< T > | makeTranslation (const Vector3< T > &translation_in) |
| Creates a transform with the given translation, identity rotation, and unit scale. | |
| static TransformT< T > | makeScale (const T &scale_in) |
| Creates a transform with the given scale, identity rotation, and zero translation. | |
| static TransformT< T > | makeRandom (bool translation=true, bool rotation=true, bool scale=true) |
| Creates a random transform. | |
| static TransformT< T > | fromAffine3 (const Affine3< T > &other) |
| Decomposes an Eigen::Affine3 into rotation, translation, and uniform scale. | |
| static TransformT< T > | fromMatrix (const Matrix4< T > &other) |
| Decomposes a 4x4 homogeneous matrix into rotation, translation, and uniform scale. | |
Public Attributes | |
| Quaternion< T > | rotation |
| Unit quaternion encoding the rotation. | |
| Vector3< T > | translation |
| T | scale |
| Uniform scale factor applied before rotation and translation. | |
Lightweight transform with separate rotation, translation, and uniform scaling.
Applied to a point as: p' = translation + rotation * (scale * p).
| T | The scalar type (float or double). |
Use Eigen::Affine3 only at IO boundaries (FBX, glTF) where the format stores 4x4 matrices. Convert via TransformT::fromAffine3() / toAffine3().
Definition at line 36 of file transform.h.
|
inline |
Creates the identity transform (zero translation, identity rotation, unit scale).
Definition at line 74 of file transform.h.
Referenced by momentum::TransformT< float >::cast(), fromAffine3(), fromMatrix(), inverse(), makeRandom(), makeRotation(), makeScale(), makeTranslation(), and momentum::TransformT< float >::operator*().
|
inlineexplicit |
| T2 | Source scalar type. |
Definition at line 78 of file transform.h.
|
inlineexplicit |
Definition at line 83 of file transform.h.
|
inlineexplicit |
Definition at line 89 of file transform.h.
|
inlineexplicit |
Definition at line 98 of file transform.h.
|
inlineexplicit |
Definition at line 103 of file transform.h.
|
inlinenodiscard |
| T2 | Target scalar type. |
Definition at line 206 of file transform.h.
Referenced by momentum::CollisionGeometryStateT< T >::updatePrimitive().
|
staticnodiscard |
Decomposes an Eigen::Affine3 into rotation, translation, and uniform scale.
Definition at line 55 of file transform.cpp.
References fromMatrix(), and TransformT().
Referenced by momentum::TransformT< float >::operator=(), and momentum::TransformT< float >::TransformT().
|
staticnodiscard |
Decomposes a 4x4 homogeneous matrix into rotation, translation, and uniform scale.
Definition at line 60 of file transform.cpp.
References TransformT().
Referenced by fromAffine3(), momentum::TransformT< float >::operator=(), and momentum::TransformT< float >::TransformT().
|
inlinenodiscard |
Returns the rotated unit-X axis (i.e.
the first column of the rotation matrix). Inlined hand-expansion of Eigen::Quaternion::toRotationMatrix() for the X column; faster than constructing the full 3x3 matrix when only one axis is needed.
Definition at line 173 of file transform.h.
Referenced by momentum::CollisionGeometryStateT< T >::updatePrimitive().
|
nodiscard |
Returns the inverse transform such that (*this) * inverse() == identity.
Definition at line 93 of file transform.cpp.
References rotation, scale, TransformT(), and translation.
Referenced by momentum::skeletonStateToJointParameters(), momentum::skeletonStateToJointParametersRespectingActiveParameters(), and momentum::transformAtoB().
|
inlinenodiscard |
Approximate equality test using tol as a relative precision.
Currently routed through the Affine3 representation; this conflates rotation, translation, and scale tolerances.
Definition at line 218 of file transform.h.
|
staticnodiscard |
Creates a random transform.
| [in] | translation | If true, sample translation uniformly in [-1, 1] per axis; otherwise zero. |
| [in] | rotation | If true, sample a uniformly random unit quaternion; otherwise identity. |
| [in] | scale | If true, sample scale uniformly in [0.5, 2.0]; otherwise 1. |
Definition at line 36 of file transform.cpp.
References rotation, scale, TransformT(), and translation.
|
staticnodiscard |
Creates a transform with the given rotation, identity translation, and unit scale.
Definition at line 21 of file transform.cpp.
References TransformT().
|
staticnodiscard |
Creates a transform with the given scale, identity rotation, and zero translation.
Definition at line 31 of file transform.cpp.
References TransformT().
|
staticnodiscard |
Creates a transform with the given translation, identity rotation, and unit scale.
Definition at line 26 of file transform.cpp.
References TransformT().
|
inlineexplicit |
Definition at line 144 of file transform.h.
|
inlinenodiscard |
Composes with an Affine3.
The result is a general Affine3 because other may contain shear or non-uniform scale that cannot be represented by a TransformT.
Definition at line 133 of file transform.h.
|
inlinenodiscard |
Composes transforms: (*this) * other applies other first, then *this.
Equivalent to multiplying the homogeneous matrices: [ s_1*R_1 t_1 ] * [ s_2*R_2 t_2 ] = [ s_1*s_2*R_1*R_2 s_1*R_1*t_2 + t_1 ] [ 0 1 ] [ 0 1 ] [ 0 1 ]
Definition at line 124 of file transform.h.
|
inlinenodiscard |
Definition at line 140 of file transform.h.
|
inline |
Definition at line 108 of file transform.h.
|
inline |
Definition at line 114 of file transform.h.
|
nodiscard |
Applies only the rotation to a direction vector (translation and scale are ignored).
Definition at line 88 of file transform.cpp.
References rotation.
|
nodiscard |
Definition at line 79 of file transform.cpp.
References rotation, scale, and translation.
Referenced by momentum::TransformT< float >::isApprox(), and momentum::TransformT< double >::operator Affine3< double >().
|
inlinenodiscard |
Returns scale * R, the linear part of the transform.
Definition at line 165 of file transform.h.
Referenced by momentum::operator*(), and momentum::TransformT< float >::operator*().
|
inlinenodiscard |
Returns the equivalent 4x4 homogeneous matrix [s*R | t; 0 0 0 1].
Definition at line 151 of file transform.h.
|
inlinenodiscard |
Returns the rotation as a 3x3 orthogonal matrix (scale not included).
Definition at line 160 of file transform.h.
Referenced by momentum::JointToJointSequenceErrorFunctionT< T >::getError(), momentum::JointToJointSequenceErrorFunctionT< T >::getGradient(), momentum::JointToJointSequenceErrorFunctionT< T >::getJacobian(), and momentum::TransformT< float >::toLinear().
|
inlinenodiscard |
Applies the full transform to a point: translation + rotation * (scale * pt).
Definition at line 193 of file transform.h.
Referenced by momentum::TransformT< float >::operator*().
| Quaternion<T> momentum::TransformT< T >::rotation |
Unit quaternion encoding the rotation.
Not enforced — callers are responsible for keeping it normalized; non-unit quaternions will scale the rotated vector.
Definition at line 39 of file transform.h.
Referenced by momentum::createCollisionBox(), momentum::createCollisionCapsule(), momentum::createCollisionEllipsoid(), momentum::StateSequenceErrorFunctionT< T >::getError(), momentum::StateSequenceErrorFunctionT< T >::getGradient(), momentum::StateSequenceErrorFunctionT< T >::getJacobian(), inverse(), momentum::loadCollisionGeometryFromUsd(), momentum::logCollisionGeometry(), momentum::detail::makeCollisionBoxLogData(), momentum::detail::makeCollisionEllipsoidLogData(), makeRandom(), momentum::TransformT< float >::operator*(), rotate(), momentum::JointStateT< T >::set(), momentum::slerp(), toAffine3(), momentum::PoseTransformSolverT< T >::transformPose(), and momentum::CollisionGeometryStateT< T >::updatePrimitive().
| T momentum::TransformT< T >::scale |
Uniform scale factor applied before rotation and translation.
Definition at line 42 of file transform.h.
Referenced by inverse(), momentum::logCollisionGeometry(), momentum::detail::makeCollisionBoxLogData(), momentum::detail::makeCollisionEllipsoidLogData(), makeRandom(), momentum::TransformT< float >::operator*(), momentum::slerp(), toAffine3(), and momentum::CollisionGeometryStateT< T >::updatePrimitive().
| Vector3<T> momentum::TransformT< T >::translation |
Definition at line 40 of file transform.h.
Referenced by momentum::createCollisionBox(), momentum::createCollisionCapsule(), momentum::createCollisionEllipsoid(), momentum::JointToJointSequenceErrorFunctionT< T >::getError(), momentum::StateSequenceErrorFunctionT< T >::getError(), momentum::JointToJointSequenceErrorFunctionT< T >::getGradient(), momentum::StateSequenceErrorFunctionT< T >::getGradient(), momentum::JointToJointSequenceErrorFunctionT< T >::getJacobian(), momentum::StateSequenceErrorFunctionT< T >::getJacobian(), inverse(), momentum::loadCollisionGeometryFromUsd(), momentum::logCollisionGeometry(), momentum::detail::makeCollisionBoxLogData(), momentum::detail::makeCollisionEllipsoidLogData(), makeRandom(), momentum::operator*(), momentum::TransformT< float >::operator*(), momentum::slerp(), toAffine3(), momentum::PoseTransformSolverT< T >::transformPose(), and momentum::CollisionGeometryStateT< T >::updatePrimitive().