mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-06-27 02:01:42 +00:00
[wpimath] Add nearest to Pose2d and Translation2d (#4882)
Co-authored-by: David Vo <auscompgeek@users.noreply.github.com>
This commit is contained in:
@@ -4,6 +4,9 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <initializer_list>
|
||||
#include <span>
|
||||
|
||||
#include <wpi/SymbolExports.h>
|
||||
|
||||
#include "Rotation2d.h"
|
||||
@@ -170,6 +173,21 @@ class WPILIB_DLLEXPORT Translation2d {
|
||||
*/
|
||||
bool operator==(const Translation2d& other) const;
|
||||
|
||||
/**
|
||||
* Returns the nearest Translation2d from a collection of translations
|
||||
* @param translations The collection of translations.
|
||||
* @return The nearest Translation2d from the collection.
|
||||
*/
|
||||
Translation2d Nearest(std::span<const Translation2d> translations) const;
|
||||
|
||||
/**
|
||||
* Returns the nearest Translation2d from a collection of translations
|
||||
* @param translations The collection of translations.
|
||||
* @return The nearest Translation2d from the collection.
|
||||
*/
|
||||
Translation2d Nearest(
|
||||
std::initializer_list<Translation2d> translations) const;
|
||||
|
||||
private:
|
||||
units::meter_t m_x = 0_m;
|
||||
units::meter_t m_y = 0_m;
|
||||
|
||||
Reference in New Issue
Block a user