[wpimath] Revert Rotation2D change that limits angles (#4781)

Reverts "[wpimath] Constrain Rotation2d range to -pi to pi (#4611)"
This reverts commit d1d458db2b.

This broke multiple teams code in beta. It is also easier to limit the angle externally, then reconstruct a larger angle that got limited. This additionally adds comments to clarify the behavior and retains tests that were added in the reverted commit, and fixes a javadoc comment angle reference.
This commit is contained in:
sciencewhiz
2022-12-08 18:10:44 -08:00
committed by GitHub
parent 0f5b08ec69
commit 989c9fb29a
7 changed files with 54 additions and 56 deletions

View File

@@ -10,16 +10,6 @@
using namespace frc;
TEST(Rotation2dTest, InScope) {
const auto rot1 = Rotation2d{units::radian_t{std::numbers::pi * 5 / 2}};
const auto rot2 = Rotation2d{units::radian_t{std::numbers::pi * 7 / 2}};
const auto rot3 = Rotation2d{270_deg};
EXPECT_DOUBLE_EQ(std::numbers::pi / 2, rot1.Radians().value());
EXPECT_DOUBLE_EQ(-std::numbers::pi / 2, rot2.Radians().value());
EXPECT_DOUBLE_EQ(-90, rot3.Degrees().value());
}
TEST(Rotation2dTest, RadiansToDegrees) {
const Rotation2d rot1{units::radian_t{std::numbers::pi / 3.0}};
const Rotation2d rot2{units::radian_t{std::numbers::pi / 4.0}};
@@ -76,8 +66,8 @@ TEST(Rotation2dTest, Inequality) {
TEST(Rotation2dTest, Constexpr) {
constexpr Rotation2d defaultCtor;
constexpr Rotation2d radianCtor{0.25_rad};
constexpr Rotation2d degreeCtor{-90_deg};
constexpr Rotation2d radianCtor{5_rad};
constexpr Rotation2d degreeCtor{270_deg};
constexpr Rotation2d rotation45{45_deg};
constexpr Rotation2d cartesianCtor{3.5, -3.5};
@@ -86,9 +76,9 @@ TEST(Rotation2dTest, Constexpr) {
constexpr auto subtracted = cartesianCtor - degreeCtor;
static_assert(defaultCtor.Radians() == 0_rad);
static_assert(degreeCtor.Degrees() == -90_deg);
static_assert(negated.Radians() == -0.25_rad);
static_assert(multiplied.Radians() == 0.5_rad);
static_assert(degreeCtor.Degrees() == 270_deg);
static_assert(negated.Radians() == -5_rad);
static_assert(multiplied.Radians() == 10_rad);
static_assert(subtracted == rotation45);
static_assert(radianCtor != degreeCtor);
}