Momentum
A library for solving nonlinear optimization problems related to human body kinematics
Loading...
Searching...
No Matches
coordinate_system.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
10#include <momentum/math/types.h>
11
12namespace momentum {
13
15enum class UpAxis {
16 X = 0,
19};
20
22enum class Handedness {
23 Left = 0,
25};
26
34
42
48
52template <typename T>
53[[nodiscard]] T scaleFactor(const CoordinateSystem& from, const CoordinateSystem& to);
54
57template <typename T>
58[[nodiscard]] Vector3<T>
59changeVector(const Vector3<T>& v, const CoordinateSystem& from, const CoordinateSystem& to);
60
64template <typename T>
65[[nodiscard]] Quaternion<T>
66changeQuaternion(const Quaternion<T>& q, const CoordinateSystem& from, const CoordinateSystem& to);
67
72template <typename T>
73[[nodiscard]] Matrix3<T>
74changeRotationMatrix(const Matrix3<T>& m, const CoordinateSystem& from, const CoordinateSystem& to);
75
76// Convenience wrappers for converting to/from Momentum's canonical coordinate system
77// (kMomentumCoordinateSystem: Y-up, right-handed, centimeters).
78
80template <typename T>
81[[nodiscard]] Vector3<T> toMomentumVector(const Vector3<T>& v, const CoordinateSystem& from);
82
84template <typename T>
85[[nodiscard]] Vector3<T> fromMomentumVector(const Vector3<T>& v, const CoordinateSystem& to);
86
88template <typename T>
90 const Quaternion<T>& q,
91 const CoordinateSystem& from);
92
94template <typename T>
96 const Quaternion<T>& q,
97 const CoordinateSystem& to);
98
100template <typename T>
102 const Matrix3<T>& m,
103 const CoordinateSystem& from);
104
106template <typename T>
108 const Matrix3<T>& m,
109 const CoordinateSystem& to);
110
111} // namespace momentum
Quaternion< T > changeQuaternion(const Quaternion< T > &q, const CoordinateSystem &from, const CoordinateSystem &to)
Converts a quaternion rotation between coordinate systems.
Matrix3< T > fromMomentumRotationMatrix(const Matrix3< T > &m, const CoordinateSystem &to)
Converts a 3x3 rotation matrix from Momentum's canonical coordinate system into to.
Eigen::Matrix< T, 3, 3 > Matrix3
Definition types.h:96
Vector3< T > toMomentumVector(const Vector3< T > &v, const CoordinateSystem &from)
Converts a position vector from from into Momentum's canonical coordinate system.
LengthUnit
Specifies the unit of length measurement.
Vector3< T > fromMomentumVector(const Vector3< T > &v, const CoordinateSystem &to)
Converts a position vector from Momentum's canonical coordinate system into to.
Quaternion< T > toMomentumQuaternion(const Quaternion< T > &q, const CoordinateSystem &from)
Converts a quaternion rotation from from into Momentum's canonical coordinate system.
Quaternion< T > fromMomentumQuaternion(const Quaternion< T > &q, const CoordinateSystem &to)
Converts a quaternion rotation from Momentum's canonical coordinate system into to.
Eigen::Quaternion< T > Quaternion
Unit quaternion representing a 3D rotation.
Definition types.h:385
Handedness
Specifies the handedness (chirality) of a coordinate system.
Matrix3< T > changeRotationMatrix(const Matrix3< T > &m, const CoordinateSystem &from, const CoordinateSystem &to)
Converts a 3x3 rotation matrix between coordinate systems.
UpAxis
Specifies which axis points "up" in a 3D coordinate system.
constexpr CoordinateSystem kMomentumCoordinateSystem
Momentum's canonical coordinate system: Y-up, right-handed, centimeters.
Vector< T, 3 > Vector3
Definition types.h:236
Vector3< T > changeVector(const Vector3< T > &v, const CoordinateSystem &from, const CoordinateSystem &to)
Converts a 3D position vector between coordinate systems.
T scaleFactor(const CoordinateSystem &from, const CoordinateSystem &to)
Returns the length scale factor when converting a length from from's unit to to's unit.
Matrix3< T > toMomentumRotationMatrix(const Matrix3< T > &m, const CoordinateSystem &from)
Converts a 3x3 rotation matrix from from into Momentum's canonical coordinate system.
A 3D coordinate system defined by its up axis, handedness, and length unit.