Momentum
A library for solving nonlinear optimization problems related to human body kinematics
Loading...
Searching...
No Matches
finite_difference_sequence_error_function.h
Go to the documentation of this file.
1/*
2 * Copyright (c) Meta Platforms, Inc. and affiliates.
3 *
4 * This source code is licensed under the MIT license found in the
5 * LICENSE file in the root directory of this source tree.
6 */
7
8#pragma once
9
13
14namespace momentum {
15
30template <typename T>
32 public:
34 const Skeleton& skel,
35 const ParameterTransform& pt,
36 const std::vector<T>& stencilCoefficients);
38 const Character& character,
39 const std::vector<T>& stencilCoefficients);
40
41 [[nodiscard]] size_t numFrames() const final {
42 return stencilCoefficients_.size();
43 }
44
45 [[nodiscard]] double getError(
46 std::span<const ModelParametersT<T>> modelParameters,
47 std::span<const SkeletonStateT<T>> skelStates,
48 std::span<const MeshStateT<T>> meshStates) const final;
49
50 [[nodiscard]] double getGradient(
51 std::span<const ModelParametersT<T>> modelParameters,
52 std::span<const SkeletonStateT<T>> skelStates,
53 std::span<const MeshStateT<T>> meshStates,
54 Eigen::Ref<Eigen::VectorX<T>> gradient) const final;
55
57 std::span<const ModelParametersT<T>> modelParameters,
58 std::span<const SkeletonStateT<T>> skelStates,
59 std::span<const MeshStateT<T>> meshStates,
60 Eigen::Ref<Eigen::MatrixX<T>> jacobian,
61 Eigen::Ref<Eigen::VectorX<T>> residual,
62 int& usedRows) const final;
63
64 [[nodiscard]] size_t getJacobianSize() const final;
65
68 void setTargetWeights(const Eigen::VectorX<T>& weights);
69
74 void setTargetValue(const Eigen::Vector3<T>& targetValue);
75
78 void setTargetValues(const std::vector<Eigen::Vector3<T>>& targetValues);
79
81 void reset();
82
83 [[nodiscard]] const Eigen::VectorX<T>& getTargetWeights() const {
84 return targetWeights_;
85 }
86
87 [[nodiscard]] const std::vector<Eigen::Vector3<T>>& getTargetValues() const {
88 return targetValues_;
89 }
90
91 [[nodiscard]] const std::vector<T>& getStencilCoefficients() const {
92 return stencilCoefficients_;
93 }
94
95 private:
96 std::vector<T> stencilCoefficients_;
97 Eigen::VectorX<T> targetWeights_;
98 std::vector<Eigen::Vector3<T>> targetValues_;
99};
100
101} // namespace momentum
double getError(std::span< const ModelParametersT< T > > modelParameters, std::span< const SkeletonStateT< T > > skelStates, std::span< const MeshStateT< T > > meshStates) const final
void setTargetValues(const std::vector< Eigen::Vector3< float > > &targetValues)
double getGradient(std::span< const ModelParametersT< T > > modelParameters, std::span< const SkeletonStateT< T > > skelStates, std::span< const MeshStateT< T > > meshStates, Eigen::Ref< Eigen::VectorX< T > > gradient) const final
void setTargetValue(const Eigen::Vector3< float > &targetValue)
double getJacobian(std::span< const ModelParametersT< T > > modelParameters, std::span< const SkeletonStateT< T > > skelStates, std::span< const MeshStateT< T > > meshStates, Eigen::Ref< Eigen::MatrixX< T > > jacobian, Eigen::Ref< Eigen::VectorX< T > > residual, int &usedRows) const final
FiniteDifferenceSequenceErrorFunctionT(const Skeleton &skel, const ParameterTransform &pt, const std::vector< T > &stencilCoefficients)
const std::vector< Eigen::Vector3< T > > & getTargetValues() const
void setTargetWeights(const Eigen::VectorX< float > &weights)
FiniteDifferenceSequenceErrorFunctionT(const Character &character, const std::vector< T > &stencilCoefficients)
SequenceErrorFunctionT(const Skeleton &skel, const ParameterTransform &pt)
Definition types.h:28
SkeletonT< float > Skeleton
Definition fwd.h:263
ParameterTransformT< float > ParameterTransform
Definition fwd.h:244
Vector< T, Dynamic > VectorX
Dynamic-size column vector. Common return type for solver residuals and parameter vectors.
Definition types.h:207
Vector< T, 3 > Vector3
Definition types.h:236
A character model with skeletal structure, mesh, and optional components.
Definition character.h:32
Represents the complete state of a model's mesh.
Definition mesh_state.h:24
A vector of size numModelParams holding the values of all model parameters for a character.
Definition types.h:99
Represents the complete state of a skeleton.