[wpimath] Add an operator for composing two Transform2ds (#3527)

This commit is contained in:
Tyler Veness
2021-08-23 20:22:48 -07:00
committed by GitHub
parent 2edd510ab7
commit e0c6cd3dcc
5 changed files with 60 additions and 5 deletions

View File

@@ -28,6 +28,10 @@ Transform2d Transform2d::Inverse() const {
return Transform2d{(-Translation()).RotateBy(-Rotation()), -Rotation()};
}
Transform2d Transform2d::operator+(const Transform2d& other) const {
return Transform2d{Pose2d{}, Pose2d{}.TransformBy(*this).TransformBy(other)};
}
bool Transform2d::operator==(const Transform2d& other) const {
return m_translation == other.m_translation && m_rotation == other.m_rotation;
}

View File

@@ -81,6 +81,13 @@ class Transform2d {
return Transform2d(m_translation * scalar, m_rotation * scalar);
}
/**
* Composes two transformations.
*
* @param other The transform to compose with this one.
*/
Transform2d operator+(const Transform2d& other) const;
/**
* Checks equality between this Transform2d and another object.
*