[wpimath] Constrain Rotation2d range to -pi to pi (#4611)

Co-authored-by: Ryan Blue <ryanzblue@gmail.com>
This commit is contained in:
ohowe
2022-11-14 15:25:15 -07:00
committed by GitHub
parent f656e99245
commit d1d458db2b
7 changed files with 69 additions and 43 deletions

View File

@@ -132,18 +132,18 @@ class WPILIB_DLLEXPORT Rotation2d {
constexpr Rotation2d RotateBy(const Rotation2d& other) const;
/**
* Returns the radian value of the rotation.
* Returns the radian value of the rotation within (-pi, pi].
*
* @return The radian value of the rotation.
*/
constexpr units::radian_t Radians() const { return m_value; }
constexpr units::radian_t Radians() const;
/**
* Returns the degree value of the rotation.
* Returns the degree value of the rotation within (-180, 180].
*
* @return The degree value of the rotation.
*/
constexpr units::degree_t Degrees() const { return m_value; }
constexpr units::degree_t Degrees() const;
/**
* Returns the cosine of the rotation.
@@ -167,7 +167,6 @@ class WPILIB_DLLEXPORT Rotation2d {
constexpr double Tan() const { return Sin() / Cos(); }
private:
units::radian_t m_value = 0_rad;
double m_cos = 1;
double m_sin = 0;
};