mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-06-19 00:41:43 +00:00
[wpimath] Add CoordinateSystem.convert() translation and rotation overloads (#4227)
This commit is contained in:
@@ -24,8 +24,8 @@ CoordinateSystem::CoordinateSystem(const CoordinateAxis& positiveX,
|
||||
R.block<3, 1>(0, 2) = positiveZ.m_axis;
|
||||
|
||||
// Require that the change of basis matrix is special orthogonal. This is true
|
||||
// if the axes used are orthogonal and normalized. The Axis class already
|
||||
// normalizes itself, so we just need to check for orthogonality.
|
||||
// if the axes used are orthogonal and normalized. The CoordinateAxis class
|
||||
// already normalizes itself, so we just need to check for orthogonality.
|
||||
if (R * R.transpose() != Matrixd<3, 3>::Identity()) {
|
||||
throw std::domain_error("Coordinate system isn't special orthogonal");
|
||||
}
|
||||
@@ -87,6 +87,18 @@ const CoordinateSystem& CoordinateSystem::NED() {
|
||||
return instance;
|
||||
}
|
||||
|
||||
Translation3d CoordinateSystem::Convert(const Translation3d& translation,
|
||||
const CoordinateSystem& from,
|
||||
const CoordinateSystem& to) {
|
||||
return translation.RotateBy(from.m_rotation - to.m_rotation);
|
||||
}
|
||||
|
||||
Rotation3d CoordinateSystem::Convert(const Rotation3d& rotation,
|
||||
const CoordinateSystem& from,
|
||||
const CoordinateSystem& to) {
|
||||
return rotation.RotateBy(from.m_rotation - to.m_rotation);
|
||||
}
|
||||
|
||||
Pose3d CoordinateSystem::Convert(const Pose3d& pose,
|
||||
const CoordinateSystem& from,
|
||||
const CoordinateSystem& to) {
|
||||
|
||||
Reference in New Issue
Block a user