Momentum
A library for solving nonlinear optimization problems related to human body kinematics
Loading...
Searching...
No Matches
locator.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
12
13namespace momentum {
14
19struct Locator {
20 std::string name;
21
23 size_t parent;
24
27
30
32 float weight;
33
36
40
43 bool attachedToSkin = false;
44
46 float skinOffset = 0.0f;
47
49 const std::string& name = "uninitialized",
50 const size_t parent = kInvalidIndex,
51 const Vector3f& offset = Vector3f::Zero(),
52 const Vector3i& locked = Vector3i::Zero(),
53 const float weight = 1.0f,
54 const Vector3f& limitOrigin = Vector3f::Zero(),
55 const Vector3f& limitWeight = Vector3f::Zero(),
56 bool attachedToSkin = false,
57 float skinOffset = 0.0f)
58 : name(name),
67
69 inline bool operator==(const Locator& locator) const {
70 return (
71 (name == locator.name) && (parent == locator.parent) && offset.isApprox(locator.offset) &&
72 locked.isApprox(locator.locked) && isApprox(weight, locator.weight) &&
73 limitOrigin.isApprox(locator.limitOrigin) && limitWeight.isApprox(locator.limitWeight) &&
75 }
76};
77
79using LocatorList = std::vector<Locator>;
80
81} // namespace momentum
bool isApprox(T l, T r, T eps=Eps< T >(1e-4, 1e-6)) noexcept
Determines if two values are approximately equal within a given tolerance.
Definition utility.h:53
Vector3< std::int32_t > Vector3i
Definition types.h:293
constexpr size_t kInvalidIndex
Sentinel value indicating an invalid or unset size_t index.
Definition types.h:182
Vector3< float > Vector3f
Definition types.h:251
std::vector< Locator > LocatorList
A collection of locators attached to a skeleton.
Definition locator.h:79
float weight
Influence weight when used as a constraint in error functions.
Definition locator.h:32
size_t parent
Index of the parent joint in the skeleton.
Definition locator.h:23
bool operator==(const Locator &locator) const
Equality comparison; uses approximate (isApprox) comparison for floating-point fields.
Definition locator.h:69
Locator(const std::string &name="uninitialized", const size_t parent=kInvalidIndex, const Vector3f &offset=Vector3f::Zero(), const Vector3i &locked=Vector3i::Zero(), const float weight=1.0f, const Vector3f &limitOrigin=Vector3f::Zero(), const Vector3f &limitWeight=Vector3f::Zero(), bool attachedToSkin=false, float skinOffset=0.0f)
Definition locator.h:48
std::string name
Definition locator.h:20
float skinOffset
Offset from the skin surface, used when solving for body shape using locators.
Definition locator.h:46
Vector3f limitWeight
Per-axis strength pulling the locator back toward limitOrigin.
Definition locator.h:39
Vector3i locked
Per-axis lock flags (x, y, z): 1 = locked, 0 = free.
Definition locator.h:29
bool attachedToSkin
True if the locator is attached to the skin of a person (e.g.
Definition locator.h:43
Vector3f offset
Position in the parent joint's local coordinate frame.
Definition locator.h:26
Vector3f limitOrigin
Reference position for limit constraints; typically equals offset when loaded.
Definition locator.h:35