[wpimath] Add Pose2d and Pose3d rotateAround() (#7659)

This commit is contained in:
ハイドラント
2025-01-13 13:55:26 -06:00
committed by GitHub
parent fc9e413ce1
commit cd92b07321
8 changed files with 98 additions and 0 deletions

View File

@@ -184,6 +184,19 @@ class WPILIB_DLLEXPORT Pose2d {
*/
constexpr Pose2d RelativeTo(const Pose2d& other) const;
/**
* Rotates the current pose around a point in 2D space.
*
* @param point The point in 2D space to rotate around.
* @param rot The rotation to rotate the pose by.
*
* @return The new rotated pose.
*/
constexpr Pose2d RotateAround(const Translation2d& point,
const Rotation2d& rot) const {
return {m_translation.RotateAround(point, rot), m_rotation.RotateBy(rot)};
}
/**
* Obtain a new Pose2d from a (constant curvature) velocity.
*

View File

@@ -207,6 +207,19 @@ class WPILIB_DLLEXPORT Pose3d {
*/
constexpr Pose3d RelativeTo(const Pose3d& other) const;
/**
* Rotates the current pose around a point in 3D space.
*
* @param point The point in 3D space to rotate around.
* @param rot The rotation to rotate the pose by.
*
* @return The new rotated pose.
*/
constexpr Pose3d RotateAround(const Translation3d& point,
const Rotation3d& rot) const {
return {m_translation.RotateAround(point, rot), m_rotation.RotateBy(rot)};
}
/**
* Obtain a new Pose3d from a (constant curvature) velocity.
*