Momentum
A library for solving nonlinear optimization problems related to human body kinematics
Loading...
Searching...
No Matches
support_polygon.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
12#include <span>
13#include <vector>
14
15namespace momentum {
16
24template <typename T>
28
30 T offset = T(0);
31
34
37
44 explicit SupportPlaneT(
45 const Vector3<T>& planeNormal = Vector3<T>::UnitY(),
46 T planeOffset = T(0),
47 const Vector3<T>& uAxisHint = Vector3<T>::UnitX());
48
50 [[nodiscard]] Vector3<T> origin() const;
51
53 [[nodiscard]] T signedDistance(const Vector3<T>& point) const;
54
56 [[nodiscard]] Vector3<T> projectPoint(const Vector3<T>& point) const;
57
59 [[nodiscard]] Vector2<T> coordinates(const Vector3<T>& point) const;
60
62 [[nodiscard]] Vector3<T> pointFromCoordinates(const Vector2<T>& point) const;
63};
64
67
74[[nodiscard]] float cross2d(const Vector2f& origin, const Vector2f& a, const Vector2f& b);
75
83[[nodiscard]] std::vector<Vector2f> computeConvexHull2d(std::span<const Vector2f> points);
84
92[[nodiscard]] std::vector<Vector2f> computeSupportPolygonFromWorldPoints(
93 std::span<const Vector3f> points,
94 const SupportPlane& supportPlane);
95
97[[nodiscard]] std::vector<Vector2f> computeSupportPolygonFromWorldPoints(
98 std::span<const Vector3f> points);
99
100} // namespace momentum
Vector2< float > Vector2f
Definition types.h:250
SupportPlaneT< double > SupportPlaned
Definition fwd.h:59
float cross2d(const Vector2f &origin, const Vector2f &a, const Vector2f &b)
Compute the signed 2D cross product of vectors from an origin.
Vector< T, 2 > Vector2
Definition types.h:234
std::vector< Vector2f > computeConvexHull2d(const std::span< const Vector2f > points)
Compute the convex hull of 2D support points.
Vector< T, 3 > Vector3
Definition types.h:236
SupportPlaneT< float > SupportPlane
Definition fwd.h:58
std::vector< Vector2f > computeSupportPolygonFromWorldPoints(const std::span< const Vector3f > points)
Compute the 2D support polygon from world-space support points on the Y-up ground plane.
Oriented plane used to classify support contacts and project support polygons.
Vector3< T > projectPoint(const Vector3< T > &point) const
Return point projected orthogonally onto the plane.
Vector3< T > pointFromCoordinates(const Vector2< T > &point) const
Return the world-space point with the given 2D support-plane coordinates.
SupportPlaneT(const Vector3< T > &planeNormal=Vector3< T >::UnitY(), T planeOffset=T(0), const Vector3< T > &uAxisHint=Vector3< T >::UnitX())
Construct an oriented support plane and in-plane coordinate basis.
Vector3< T > origin() const
Return one world-space point on the plane, equal to normal * offset.
Vector2< T > coordinates(const Vector3< T > &point) const
Return 2D support-plane coordinates of point after projection.
T signedDistance(const Vector3< T > &point) const
Return normal.dot(point) - offset; negative values are below/behind the plane.