Momentum
A library for solving nonlinear optimization problems related to human body kinematics
Loading...
Searching...
No Matches
locator_state.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
15 const SkeletonState& skeletonState,
16 const LocatorList& referenceLocators) noexcept {
17 const size_t numLocators = referenceLocators.size();
18
19 position.resize(numLocators);
20
21 const auto& jointState = skeletonState.jointState;
22
23 for (size_t locatorID = 0; locatorID < numLocators; locatorID++) {
24 const Locator& locator = referenceLocators[locatorID];
25
26 const size_t& parentId = locator.parent;
27
28 // Transform each locator by its parent joint's world transform.
29 position[locatorID] = jointState[parentId].transform * locator.offset;
30 }
31}
32
33} // namespace momentum
SkeletonStateT< float > SkeletonState
Definition fwd.h:282
std::vector< Locator > LocatorList
A collection of locators attached to a skeleton.
Definition locator.h:79
std::vector< Vector3f > position
World-space positions of all locators, updated when the skeleton moves.
void update(const SkeletonState &skeletonState, const LocatorList &referenceLocators) noexcept
Updates the world positions of all locators based on the current skeleton pose.
Represents a point attached to a joint in a skeleton.
Definition locator.h:19
size_t parent
Index of the parent joint in the skeleton.
Definition locator.h:23
Vector3f offset
Position in the parent joint's local coordinate frame.
Definition locator.h:26