27 value = std::fmodf(value, M_2PI);
47 : value_(
Calculate(static_cast<float>(value))) {}
55 while (value_ >= M_2PI) {
86 return CycleValue(
static_cast<float>(value) + value_);
117 value_ =
Calculate(
static_cast<float>(value) + value_);
128 value_ =
Calculate(value.value_ + value_);
140 float ans = value_ - value;
141 while (ans >= M_PI) {
145 while (ans < -M_PI) {
159 float value =
Calculate(
static_cast<float>(raw_value));
160 float ans = value_ - value;
161 while (ans >= M_PI) {
165 while (ans < -M_PI) {
179 float ans = value_ - value.value_;
180 while (ans >= M_PI) {
184 while (ans < -M_PI) {
203 operator float() {
return this->value_; }
223 value_ =
Calculate(
static_cast<float>(value));
A class to represent and manipulate cyclic values (e.g., angles).
CycleValue & operator=(const float &value)
Assigns a float value.
CycleValue(const float &value)
Constructs a CycleValue object from a float.
float operator-(const CycleValue &value)
Computes the difference between this value and another CycleValue.
float Value()
Returns the current value.
CycleValue operator+=(const double &value)
In-place addition of a double value.
static float Calculate(float value)
Normalizes a value to the range [0, 2π).
CycleValue operator+(const double &value)
Adds a double value and returns the resulting CycleValue.
float operator-(const double &raw_value)
Computes the difference between this value and a double value.
CycleValue operator-()
Negates the current value.
CycleValue operator+=(const float &value)
In-place addition of a float value.
CycleValue operator+(const float &value)
Adds a float value and returns the resulting CycleValue.
CycleValue()
Default constructor. Initializes the value to 0.
CycleValue & operator=(const double &value)
Assigns a double value.
CycleValue & operator=(const CycleValue &)=default
Default copy assignment operator.
CycleValue operator+=(const CycleValue &value)
In-place addition of another CycleValue.
CycleValue(const double &value)
Constructs a CycleValue object from a double.
CycleValue(const CycleValue &value)
Copy constructor. Ensures the copied value remains within [0, 2π).
CycleValue operator+(const CycleValue &value)
Adds another CycleValue and returns the result.
float operator-(const float &raw_value)
Computes the difference between this value and a float value.
Represents Euler angles with cyclic values for yaw, pitch, and roll.
Represents a quaternion (w, x, y, z components).