mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-06-27 02:01:42 +00:00
[wpimath] Add vector projection and geometry vector conversions (#6343)
This commit is contained in:
@@ -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.
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user