[wpimath] Add vector projection and geometry vector conversions (#6343)

This commit is contained in:
Asa Paparo
2024-02-10 13:43:58 -05:00
committed by GitHub
parent 3207795d0d
commit 62cba9a4d3
21 changed files with 234 additions and 24 deletions

View File

@@ -7,6 +7,7 @@
#include <initializer_list>
#include <span>
#include <Eigen/Core>
#include <wpi/SymbolExports.h>
#include <wpi/json_fwd.h>
@@ -48,6 +49,14 @@ class WPILIB_DLLEXPORT Translation2d {
*/
constexpr Translation2d(units::meter_t distance, const Rotation2d& angle);
/**
* Constructs a Translation2d from the provided translation vector's X and Y
* components. The values are assumed to be in meters.
*
* @param vector The translation vector to represent.
*/
explicit Translation2d(const Eigen::Vector2d& vector);
/**
* Calculates the distance between two translations in 2D space.
*
@@ -73,6 +82,13 @@ class WPILIB_DLLEXPORT Translation2d {
*/
constexpr units::meter_t Y() const { return m_y; }
/**
* Returns a vector representation of this translation.
*
* @return A Vector representation of this translation.
*/
constexpr Eigen::Vector2d ToVector() const;
/**
* Returns the norm, or distance from the origin to the translation.
*