mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-07-04 03:11:43 +00:00
[wpimath] Make geometry classes constexpr (#7222)
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user