[wpimath] Add 2D to 3D geometry constructors (#7380)

This commit is contained in:
Joseph Eng
2024-11-12 15:18:37 -08:00
committed by GitHub
parent 6adad7bad7
commit 425bf83036
8 changed files with 70 additions and 0 deletions

View File

@@ -8,6 +8,7 @@
#include <wpi/SymbolExports.h>
#include "frc/geometry/Transform2d.h"
#include "frc/geometry/Translation3d.h"
namespace frc {
@@ -55,6 +56,17 @@ class WPILIB_DLLEXPORT Transform3d {
*/
constexpr Transform3d() = default;
/**
* Constructs a 3D transform from a 2D transform in the X-Y plane.
**
* @param transform The 2D transform.
* @see Rotation3d(Rotation2d)
* @see Translation3d(Translation2d)
*/
constexpr explicit Transform3d(const frc::Transform2d& transform)
: m_translation{frc::Translation3d{transform.Translation()}},
m_rotation{frc::Rotation3d{transform.Rotation()}} {}
/**
* Returns the translation component of the transformation.
*