[wpimath] Make geometry classes constexpr (#7222)

This commit is contained in:
Tyler Veness
2024-10-18 16:08:41 -07:00
committed by GitHub
parent 2054d0f57e
commit 95b9bd880b
30 changed files with 1324 additions and 1114 deletions

View File

@@ -11,6 +11,7 @@
#include "units/math.h"
namespace frc {
/**
* A change in distance along a 2D arc since the last pose update. We can use
* ideas from differential calculus to create new Pose2ds from a Twist2d and
@@ -40,7 +41,7 @@ struct WPILIB_DLLEXPORT Twist2d {
* @param other The other object.
* @return Whether the two objects are equal.
*/
bool operator==(const Twist2d& other) const {
constexpr bool operator==(const Twist2d& other) const {
return units::math::abs(dx - other.dx) < 1E-9_m &&
units::math::abs(dy - other.dy) < 1E-9_m &&
units::math::abs(dtheta - other.dtheta) < 1E-9_rad;
@@ -56,6 +57,7 @@ struct WPILIB_DLLEXPORT Twist2d {
return Twist2d{dx * factor, dy * factor, dtheta * factor};
}
};
} // namespace frc
#ifndef NO_PROTOBUF