mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-06-19 00:41:43 +00:00
Add equality comparator to geometry classes (#1882)
This commit is contained in:
committed by
Peter Johnson
parent
62f07c182c
commit
86b666bba9
@@ -52,6 +52,14 @@ Rotation2d& Rotation2d::operator-=(const Rotation2d& other) {
|
||||
|
||||
Rotation2d Rotation2d::operator-() const { return Rotation2d(-m_value); }
|
||||
|
||||
bool Rotation2d::operator==(const Rotation2d& other) const {
|
||||
return units::math::abs(m_value - other.m_value) < 1E-9_rad;
|
||||
}
|
||||
|
||||
bool Rotation2d::operator!=(const Rotation2d& other) const {
|
||||
return !operator==(other);
|
||||
}
|
||||
|
||||
Rotation2d Rotation2d::RotateBy(const Rotation2d& other) const {
|
||||
return {Cos() * other.Cos() - Sin() * other.Sin(),
|
||||
Cos() * other.Sin() + Sin() * other.Cos()};
|
||||
|
||||
Reference in New Issue
Block a user