Momentum
A library for solving nonlinear optimization problems related to human body kinematics
Loading...
Searching...
No Matches
normal_error_function.cpp
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
9
11
12namespace momentum {
13
14template <typename T>
16 const size_t constrIndex,
17 const JointStateT<T>& state,
18 Vector<T, 1>& f,
19 std::array<Vector3<T>, 2>& v,
20 std::array<Eigen::Matrix<T, 1, 3>, 2>& dfdv) const {
22
23 const NormalDataT<T>& constr = this->constraints_[constrIndex];
24 v[0] = state.transform * constr.localPoint;
25 v[1] = state.rotation() * constr.localNormal;
26 const Vector3<T> dist = v[0] - constr.globalPoint;
27
28 f[0] = v[1].dot(dist);
29 dfdv[0] = v[1].transpose();
30 dfdv[1] = dist.transpose();
31}
32
33template class NormalErrorFunctionT<float>;
34template class NormalErrorFunctionT<double>;
35
36} // namespace momentum
The NormalErrorFunction computes a "point-to-plane" (signed) distance from a target point to the plan...
void evalFunction(size_t constrIndex, const JointStateT< T > &state, Vector< T, 1 > &f, std::array< Vector3< T >, 2 > &v, std::array< Eigen::Matrix< T, 1, 3 >, 2 > &dfdv) const final
Eigen::Matrix< T, Dim, 1, Options > Vector
Column vector alias (an Nx1 Eigen matrix).
Definition types.h:203
Vector< T, 3 > Vector3
Definition types.h:236
Profiling macros that dispatch to one of three backends, selected at compile time:
#define MT_PROFILE_FUNCTION()
Definition profile.h:110
Represents the state of a joint with local and global transformations.
Definition joint_state.h:50
TransformT< T > transform
Global transformation in world space.
Definition joint_state.h:59
const Quaternion< T > & rotation() const
Access the joint's global rotation quaternion.
Normal constraint data: data needed to compute the point-to-plane distance for "data-to-template" in ...
Vector3< T > localNormal
The template normal defined in the local space.
Vector3< T > localPoint
The template point defined in the local space.
Vector3< T > globalPoint
The data point in world space.