Momentum
A library for solving nonlinear optimization problems related to human body kinematics
Loading...
Searching...
No Matches
vertex_plane_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
11
12namespace momentum {
13
17template <typename T>
20 Eigen::Vector3<T> normal = Eigen::Vector3<T>::UnitY();
21
23 Eigen::Vector3<T> point = Eigen::Vector3<T>::Zero();
24
26 bool above = false;
27
28 VertexPlaneDataT() = default;
30 size_t vIndex,
31 const Eigen::Vector3<T>& n,
32 const Eigen::Vector3<T>& p,
33 bool abv,
34 float w,
35 const std::string& nm = "")
36 : VertexConstraintData(vIndex, w, nm), normal(n), point(p), above(abv) {}
37};
38
48template <typename T>
49class VertexPlaneErrorFunctionT : public VertexErrorFunctionT<T, VertexPlaneDataT<T>, 1> {
50 public:
52 using typename Base::DfdvType;
53 using typename Base::FuncType;
54
56 const Character& character,
57 const ParameterTransform& parameterTransform,
58 const T& lossAlpha = GeneralizedLossT<T>::kL2,
59 const T& lossC = T(1));
60
61 ~VertexPlaneErrorFunctionT() override = default;
62
64 size_t constrIndex,
65 const SkeletonStateT<T>& state,
66 const MeshStateT<T>& meshState,
67 std::span<const Eigen::Vector3<T>> worldVecs,
68 FuncType& f,
69 std::span<DfdvType> dfdv) const final;
70};
71
72} // namespace momentum
static constexpr T kL2
Special-case alpha values that are either at a singularity in the general formula or simplify to a cl...
VertexErrorFunctionT(const Character &character, const ParameterTransform &parameterTransform, const T &lossAlpha=GeneralizedLossT< T >::kL2, const T &lossC=T(1))
Eigen::Matrix< T, FuncDim, 1 > FuncType
Eigen::Matrix< T, FuncDim, 3 > DfdvType
VertexErrorFunctionT< float, VertexPlaneDataT< float >, 1 > Base
void evalFunction(size_t constrIndex, const SkeletonStateT< T > &state, const MeshStateT< T > &meshState, std::span< const Eigen::Vector3< T > > worldVecs, FuncType &f, std::span< DfdvType > dfdv) const final
Computes the residual and derivatives.
~VertexPlaneErrorFunctionT() override=default
VertexPlaneErrorFunctionT(const Character &character, const ParameterTransform &parameterTransform, const T &lossAlpha=GeneralizedLossT< T >::kL2, const T &lossC=T(1))
ParameterTransformT< float > ParameterTransform
Definition fwd.h:244
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
Represents the complete state of a skeleton.
Eigen::Vector3< T > point
A point on the plane.
VertexPlaneDataT(size_t vIndex, const Eigen::Vector3< T > &n, const Eigen::Vector3< T > &p, bool abv, float w, const std::string &nm="")
Eigen::Vector3< T > normal
Plane normal (must be normalized).
bool above
If true, constrain vertex to be above the plane (half-space).