[wpimath] Make C++ geometry classes immutable (#3249)

This commit is contained in:
Prateek Machiraju
2021-03-19 16:38:54 -04:00
committed by GitHub
parent da96707dca
commit d3e45c297c
8 changed files with 2 additions and 126 deletions

View File

@@ -38,24 +38,10 @@ Rotation2d Rotation2d::operator+(const Rotation2d& other) const {
return RotateBy(other);
}
Rotation2d& Rotation2d::operator+=(const Rotation2d& other) {
double cos = Cos() * other.Cos() - Sin() * other.Sin();
double sin = Cos() * other.Sin() + Sin() * other.Cos();
m_cos = cos;
m_sin = sin;
m_value = units::radian_t(std::atan2(m_sin, m_cos));
return *this;
}
Rotation2d Rotation2d::operator-(const Rotation2d& other) const {
return *this + -other;
}
Rotation2d& Rotation2d::operator-=(const Rotation2d& other) {
*this += -other;
return *this;
}
Rotation2d Rotation2d::operator-() const {
return Rotation2d(-m_value);
}