mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-06-20 00:51:42 +00:00
Merge branch '2022'
This commit is contained in:
@@ -20,12 +20,6 @@ Pose2d Pose2d::operator+(const Transform2d& other) const {
|
||||
return TransformBy(other);
|
||||
}
|
||||
|
||||
Pose2d& Pose2d::operator+=(const Transform2d& other) {
|
||||
m_translation += other.Translation().RotateBy(m_rotation);
|
||||
m_rotation += other.Rotation();
|
||||
return *this;
|
||||
}
|
||||
|
||||
Transform2d Pose2d::operator-(const Pose2d& other) const {
|
||||
const auto pose = this->RelativeTo(other);
|
||||
return Transform2d(pose.Translation(), pose.Rotation());
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
@@ -33,21 +33,10 @@ Translation2d Translation2d::operator+(const Translation2d& other) const {
|
||||
return {X() + other.X(), Y() + other.Y()};
|
||||
}
|
||||
|
||||
Translation2d& Translation2d::operator+=(const Translation2d& other) {
|
||||
m_x += other.m_x;
|
||||
m_y += other.m_y;
|
||||
return *this;
|
||||
}
|
||||
|
||||
Translation2d Translation2d::operator-(const Translation2d& other) const {
|
||||
return *this + -other;
|
||||
}
|
||||
|
||||
Translation2d& Translation2d::operator-=(const Translation2d& other) {
|
||||
*this += -other;
|
||||
return *this;
|
||||
}
|
||||
|
||||
Translation2d Translation2d::operator-() const {
|
||||
return {-m_x, -m_y};
|
||||
}
|
||||
@@ -56,12 +45,6 @@ Translation2d Translation2d::operator*(double scalar) const {
|
||||
return {scalar * m_x, scalar * m_y};
|
||||
}
|
||||
|
||||
Translation2d& Translation2d::operator*=(double scalar) {
|
||||
m_x *= scalar;
|
||||
m_y *= scalar;
|
||||
return *this;
|
||||
}
|
||||
|
||||
Translation2d Translation2d::operator/(double scalar) const {
|
||||
return *this * (1.0 / scalar);
|
||||
}
|
||||
@@ -75,11 +58,6 @@ bool Translation2d::operator!=(const Translation2d& other) const {
|
||||
return !operator==(other);
|
||||
}
|
||||
|
||||
Translation2d& Translation2d::operator/=(double scalar) {
|
||||
*this *= (1.0 / scalar);
|
||||
return *this;
|
||||
}
|
||||
|
||||
void frc::to_json(wpi::json& json, const Translation2d& translation) {
|
||||
json = wpi::json{{"x", translation.X().to<double>()},
|
||||
{"y", translation.Y().to<double>()}};
|
||||
|
||||
@@ -115,7 +115,7 @@ Trajectory TrajectoryGenerator::GenerateTrajectory(
|
||||
const Transform2d flip{Translation2d(), Rotation2d(180_deg)};
|
||||
if (config.IsReversed()) {
|
||||
for (auto& waypoint : newWaypoints) {
|
||||
waypoint += flip;
|
||||
waypoint = waypoint + flip;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user