mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-06-20 00:51:42 +00:00
[wpimath] Add CoordinateSystem conversion for Transform3d (#4443)
I also refactored Pose3d's conversion implementation to use the Translation3d and Rotation3d conversions, thereby giving Translation3d and Rotation3d test coverage. No changes were made to the expected values of the Pose3d conversion tests. The expected values of the Transform3d conversion tests were copied from the Pose3d conversion tests without modification.
This commit is contained in:
@@ -61,6 +61,13 @@ Rotation3d CoordinateSystem::Convert(const Rotation3d& rotation,
|
||||
Pose3d CoordinateSystem::Convert(const Pose3d& pose,
|
||||
const CoordinateSystem& from,
|
||||
const CoordinateSystem& to) {
|
||||
return pose.RelativeTo(
|
||||
Pose3d{Translation3d{}, to.m_rotation - from.m_rotation});
|
||||
return Pose3d{Convert(pose.Translation(), from, to),
|
||||
Convert(pose.Rotation(), from, to)};
|
||||
}
|
||||
|
||||
Transform3d CoordinateSystem::Convert(const Transform3d& transform,
|
||||
const CoordinateSystem& from,
|
||||
const CoordinateSystem& to) {
|
||||
return Transform3d{Convert(transform.Translation(), from, to),
|
||||
Convert(transform.Rotation(), from, to)};
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user