Momentum
A library for solving nonlinear optimization problems related to human body kinematics
Loading...
Searching...
No Matches
momentum::SkinnedLocatorErrorFunctionT< T > Class Template Reference

Error function for skinned locator constraints. More...

#include <skinned_locator_error_function.h>

Inheritance diagram for momentum::SkinnedLocatorErrorFunctionT< T >:

Public Member Functions

 SkinnedLocatorErrorFunctionT (const Character &character_in)
 Constructs a skinned locator error function for the given character.
 ~SkinnedLocatorErrorFunctionT () override
 SkinnedLocatorErrorFunctionT (const SkinnedLocatorErrorFunctionT< T > &other)=delete
SkinnedLocatorErrorFunctionT< T > & operator= (const SkinnedLocatorErrorFunctionT< T > &other)=delete
 SkinnedLocatorErrorFunctionT (SkinnedLocatorErrorFunctionT< T > &&other)=delete
SkinnedLocatorErrorFunctionT< T > & operator= (SkinnedLocatorErrorFunctionT< T > &&other)=delete
double getError (const ModelParametersT< T > &modelParameters, const SkeletonStateT< T > &state, const MeshStateT< T > &) final
 Computes the total error for all skinned locator constraints.
double getGradient (const ModelParametersT< T > &modelParameters, const SkeletonStateT< T > &state, const MeshStateT< T > &, Eigen::Ref< Eigen::VectorX< T > > gradient) final
 Computes the gradient of the error function with respect to model parameters.
double getJacobian (const ModelParametersT< T > &modelParameters, const SkeletonStateT< T > &state, const MeshStateT< T > &, Eigen::Ref< Eigen::MatrixX< T > > jacobian, Eigen::Ref< Eigen::VectorX< T > > residual, int &usedRows) final
 Computes the Jacobian matrix and residual vector for the error function.
size_t getJacobianSize () const final
 Returns the number of rows needed for the Jacobian matrix.
void addConstraint (int locatorIndex, T weight, const Eigen::Vector3< T > &targetPosition)
 Adds a new skinned locator constraint.
void clearConstraints ()
 Removes all constraints.
void setConstraints (const std::vector< SkinnedLocatorConstraintT< T > > &constraints)
 Sets all constraints at once, replacing any existing constraints.
const std::vector< SkinnedLocatorConstraintT< T > > & getConstraints () const
 Returns the current list of constraints.
const Character * getCharacter () const override
 Returns the character associated with this error function.
Public Member Functions inherited from momentum::SkeletonErrorFunctionT< T >
 SkeletonErrorFunctionT (const Skeleton &skel, const ParameterTransform &pt)
virtual ~SkeletonErrorFunctionT ()=default
const Skeleton & getSkeleton () const
const ParameterTransform & getParameterTransform () const
void setWeight (T w)
T getWeight () const
void setActiveJoints (const VectorX< bool > &aj)
void setEnabledParameters (const ParameterSet &ps)
virtual void getHessian (const ModelParametersT< T > &, const SkeletonStateT< T > &, const MeshStateT< T > &, Eigen::Ref< Eigen::MatrixX< T > >)
virtual double getSolverDerivatives (const ModelParametersT< T > &parameters, const SkeletonStateT< T > &state, const MeshStateT< T > &meshState, const size_t actualParameters, Eigen::MatrixX< T > &hess, Eigen::VectorX< T > &grad)
virtual bool needsMesh () const

Additional Inherited Members

Protected Attributes inherited from momentum::SkeletonErrorFunctionT< T >
const Skeleton & skeleton_
const ParameterTransform & parameterTransform_
T weight_
VectorX< bool > activeJointParams_
ParameterSet enabledParameters_
bool useHessian_ {false}

Detailed Description

template<typename T>
class momentum::SkinnedLocatorErrorFunctionT< T >

Error function for skinned locator constraints.

This error function computes the error between skinned locator positions and their target positions. Skinned locators are points that are deformed by the character's skeleton and can be used to constrain the character to specific world positions. The error is computed as the weighted squared distance between the current skinned locator position and the target position.

Definition at line 47 of file skinned_locator_error_function.h.

Constructor & Destructor Documentation

◆ SkinnedLocatorErrorFunctionT() [1/3]

template<typename T>
momentum::SkinnedLocatorErrorFunctionT< T >::SkinnedLocatorErrorFunctionT ( const Character & character_in)
explicit

Constructs a skinned locator error function for the given character.

Definition at line 26 of file skinned_locator_error_function.cpp.

References momentum::SkeletonErrorFunctionT< T >::SkeletonErrorFunctionT().

◆ ~SkinnedLocatorErrorFunctionT()

template<typename T>
momentum::SkinnedLocatorErrorFunctionT< T >::~SkinnedLocatorErrorFunctionT ( )
overridedefault

◆ SkinnedLocatorErrorFunctionT() [2/3]

template<typename T>
momentum::SkinnedLocatorErrorFunctionT< T >::SkinnedLocatorErrorFunctionT ( const SkinnedLocatorErrorFunctionT< T > & other)
delete

◆ SkinnedLocatorErrorFunctionT() [3/3]

template<typename T>
momentum::SkinnedLocatorErrorFunctionT< T >::SkinnedLocatorErrorFunctionT ( SkinnedLocatorErrorFunctionT< T > && other)
delete

Member Function Documentation

◆ addConstraint()

template<typename T>
void momentum::SkinnedLocatorErrorFunctionT< T >::addConstraint ( int locatorIndex,
T weight,
const Eigen::Vector3< T > & targetPosition )

Adds a new skinned locator constraint.

Parameters
locatorIndexIndex of the skinned locator in the character
weightWeight for this constraint
targetPositionTarget position in world space

Definition at line 39 of file skinned_locator_error_function.cpp.

References MT_CHECK.

◆ clearConstraints()

template<typename T>
void momentum::SkinnedLocatorErrorFunctionT< T >::clearConstraints ( )

Removes all constraints.

Definition at line 34 of file skinned_locator_error_function.cpp.

◆ getCharacter()

template<typename T>
const Character * momentum::SkinnedLocatorErrorFunctionT< T >::getCharacter ( ) const
inlinenodiscardoverridevirtual

Returns the character associated with this error function.

Reimplemented from momentum::SkeletonErrorFunctionT< T >.

Definition at line 120 of file skinned_locator_error_function.h.

◆ getConstraints()

template<typename T>
const std::vector< SkinnedLocatorConstraintT< T > > & momentum::SkinnedLocatorErrorFunctionT< T >::getConstraints ( ) const
inlinenodiscard

Returns the current list of constraints.

Definition at line 115 of file skinned_locator_error_function.h.

◆ getError()

template<typename T>
double momentum::SkinnedLocatorErrorFunctionT< T >::getError ( const ModelParametersT< T > & modelParameters,
const SkeletonStateT< T > & state,
const MeshStateT< T > &  )
nodiscardfinalvirtual

Computes the total error for all skinned locator constraints.

Parameters
modelParametersThe current model parameters
stateThe current skeleton state
Returns
The sum of weighted squared distances between locators and targets

Reimplemented from momentum::SkeletonErrorFunctionT< T >.

Definition at line 85 of file skinned_locator_error_function.cpp.

References momentum::SkinnedLocatorConstraintT< T >::locatorIndex, MT_PROFILE_FUNCTION, momentum::SkinnedLocatorConstraintT< T >::targetPosition, momentum::SkinnedLocatorConstraintT< T >::weight, and momentum::SkeletonErrorFunctionT< T >::weight_.

◆ getGradient()

template<typename T>
double momentum::SkinnedLocatorErrorFunctionT< T >::getGradient ( const ModelParametersT< T > & modelParameters,
const SkeletonStateT< T > & state,
const MeshStateT< T > & ,
Eigen::Ref< Eigen::VectorX< T > > gradient )
finalvirtual

Computes the gradient of the error function with respect to model parameters.

Parameters
modelParametersThe current model parameters
stateThe current skeleton state
gradientOutput gradient vector to be filled
Returns
The total error value

Reimplemented from momentum::SkeletonErrorFunctionT< T >.

Definition at line 290 of file skinned_locator_error_function.cpp.

References momentum::SkeletonErrorFunctionT< T >::weight_.

◆ getJacobian()

template<typename T>
double momentum::SkinnedLocatorErrorFunctionT< T >::getJacobian ( const ModelParametersT< T > & modelParameters,
const SkeletonStateT< T > & state,
const MeshStateT< T > & ,
Eigen::Ref< Eigen::MatrixX< T > > jacobian,
Eigen::Ref< Eigen::VectorX< T > > residual,
int & usedRows )
finalvirtual

Computes the Jacobian matrix and residual vector for the error function.

Parameters
modelParametersThe current model parameters
stateThe current skeleton state
jacobianOutput Jacobian matrix to be filled
residualOutput residual vector to be filled
usedRowsNumber of rows used in the Jacobian (output parameter)
Returns
The total error value

Reimplemented from momentum::SkeletonErrorFunctionT< T >.

Definition at line 306 of file skinned_locator_error_function.cpp.

References MT_CHECK, and momentum::EigenStrongType< Derived, EigenType >::size().

◆ getJacobianSize()

template<typename T>
size_t momentum::SkinnedLocatorErrorFunctionT< T >::getJacobianSize ( ) const
nodiscardfinalvirtual

Returns the number of rows needed for the Jacobian matrix.

Reimplemented from momentum::SkeletonErrorFunctionT< T >.

Definition at line 335 of file skinned_locator_error_function.cpp.

◆ operator=() [1/2]

template<typename T>
SkinnedLocatorErrorFunctionT< T > & momentum::SkinnedLocatorErrorFunctionT< T >::operator= ( const SkinnedLocatorErrorFunctionT< T > & other)
delete

◆ operator=() [2/2]

template<typename T>
SkinnedLocatorErrorFunctionT< T > & momentum::SkinnedLocatorErrorFunctionT< T >::operator= ( SkinnedLocatorErrorFunctionT< T > && other)
delete

◆ setConstraints()

template<typename T>
void momentum::SkinnedLocatorErrorFunctionT< T >::setConstraints ( const std::vector< SkinnedLocatorConstraintT< T > > & constraints)

Sets all constraints at once, replacing any existing constraints.

Parameters
constraintsVector of constraints to set

Definition at line 48 of file skinned_locator_error_function.cpp.


The documentation for this class was generated from the following files: