[wpimath] Add RotateBy() function to pose classes (#5491)

Fixes #5472.
This commit is contained in:
Tyler Veness
2023-07-31 21:16:44 -07:00
committed by GitHub
parent 26d6e68c8f
commit 35a8b129d9
10 changed files with 139 additions and 0 deletions

View File

@@ -138,6 +138,16 @@ public class Pose2d implements Interpolatable<Pose2d> {
return times(1.0 / scalar);
}
/**
* Rotates the pose around the origin and returns the new pose.
*
* @param other The rotation to transform the pose by.
* @return The transformed pose.
*/
public Pose2d rotateBy(Rotation2d other) {
return new Pose2d(m_translation.rotateBy(other), m_rotation.rotateBy(other));
}
/**
* Transforms the pose by the given transformation and returns the new pose. See + operator for
* the matrix multiplication performed.

View File

@@ -150,6 +150,16 @@ public class Pose3d implements Interpolatable<Pose3d> {
return times(1.0 / scalar);
}
/**
* Rotates the pose around the origin and returns the new pose.
*
* @param other The rotation to transform the pose by.
* @return The transformed pose.
*/
public Pose3d rotateBy(Rotation3d other) {
return new Pose3d(m_translation.rotateBy(other), m_rotation.rotateBy(other));
}
/**
* Transforms the pose by the given transformation and returns the new pose.
*