24 #include <argos3/core/utility/datatypes/datatypes.h>
25 #include <argos3/core/utility/math/general.h>
26 #include <argos3/core/utility/math/range.h>
32 #define ARGOS_PI 3.14159265358979323846264338327950288
120 return Abs(m_fValue);
154 m_fValue = -m_fValue;
167 m_fValue += c_radians.m_fValue;
172 m_fValue -= c_radians.m_fValue;
188 cResult += c_radians;
194 cResult -= c_radians;
212 return m_fValue / c_radians.m_fValue;
222 return m_fValue < c_radians.m_fValue;
226 return m_fValue <= c_radians.m_fValue;
230 return m_fValue > c_radians.m_fValue;
234 return m_fValue >= c_radians.m_fValue;
238 return m_fValue == c_radians.m_fValue;
242 return m_fValue != c_radians.m_fValue;
257 << c_radians.m_fValue
267 is >> c_radians.m_fValue;
315 m_fValue = f_value / DEGREES_TO_RADIANS;
331 return Abs(m_fValue);
348 SIGNED_RANGE.WrapValue(*
this);
358 UNSIGNED_RANGE.WrapValue(*
this);
371 m_fValue += c_degrees.m_fValue;
376 m_fValue -= c_degrees.m_fValue;
392 cResult += c_degrees;
398 cResult -= c_degrees;
416 return m_fValue / c_degrees.m_fValue;
426 return m_fValue < c_degrees.m_fValue;
430 return m_fValue <= c_degrees.m_fValue;
434 return m_fValue > c_degrees.m_fValue;
438 return m_fValue >= c_degrees.m_fValue;
442 return m_fValue == c_degrees.m_fValue;
446 return m_fValue != c_degrees.m_fValue;
461 << c_degrees.m_fValue
468 is >> c_degrees.m_fValue;
477 static const Real DEGREES_TO_RADIANS;
499 return CRadians(c_degrees.m_fValue * CDegrees::DEGREES_TO_RADIANS);
513 cResult.m_fValue =
Mod(c_angle1.m_fValue - c_angle2.m_fValue +
CRadians::PI.m_fValue,
531 cResult.m_fValue =
Mod(c_angle1.m_fValue - c_angle2.m_fValue + 180.0f, 360.0f);
532 if(cResult.m_fValue < 0.0f) cResult.m_fValue += 360.0f;
533 cResult.m_fValue -= 180.0f;
541 #ifdef ARGOS_USE_DOUBLE
543 # define ARGOS_SINCOS ::sincos
545 # define ARGOS_SINCOS ::__sincos
547 # define ARGOS_SIN ::sin
548 # define ARGOS_ASIN ::asin
549 # define ARGOS_COS ::cos
550 # define ARGOS_ACOS ::acos
551 # define ARGOS_TAN ::tan
552 # define ARGOS_ATAN2 ::atan2
555 # define ARGOS_SINCOS ::sincosf
557 # define ARGOS_SINCOS ::__sincosf
559 # define ARGOS_SIN ::sinf
560 # define ARGOS_ASIN ::asinf
561 # define ARGOS_COS ::cosf
562 # define ARGOS_ACOS ::acosf
563 # define ARGOS_TAN ::tanf
564 # define ARGOS_ATAN2 ::atan2f
float Real
Collects all ARGoS code.
The namespace containing all the ARGoS related code.
CRadians ACos(Real f_value)
Computes the arccosine of the passed value.
Real Cos(const CRadians &c_radians)
Computes the cosine of the passed value in radians.
CRadians NormalizedDifference(const CRadians &c_angle1, const CRadians &c_angle2)
Calculates the normalized difference between the given angles.
CDegrees ToDegrees(const CRadians &c_radians)
Converts CRadians to CDegrees.
Real Tan(const CRadians &c_radians)
Computes the tangent of the passed value in radians.
void SinCos(const CRadians &c_radians, Real &f_sin, Real &f_cos)
Computes the sine and cosine of the passed value in radians.
Real Sin(const CRadians &c_radians)
Computes the sine of the passed value in radians.
CRadians ATan2(const Real f_y, const Real f_x)
Computes the arctangent of the passed values.
CRadians ToRadians(const CDegrees &c_degrees)
Converts CDegrees to CRadians.
T Abs(const T &t_v)
Returns the absolute value of the passed argument.
CRadians ASin(Real f_value)
Computes the arcsine of the passed value.
It defines the basic type CRadians, used to store an angle value in radians.
CRadians & UnsignedNormalize()
Normalizes the value in the range [0:TWO_PI].
CRadians & operator-=(const CRadians &c_radians)
CRadians(Real f_value)
Class constructor It initializes m_fValue to the passed value.
static const CRadians PI
The PI constant.
static const CRange< CRadians > SIGNED_RANGE
The signed normalization range [-PI:PI].
bool operator<=(const CRadians &c_radians) const
bool operator!=(const CRadians &c_radians) const
CRadians operator*(Real f_value) const
void SetValue(Real f_value)
Sets the value in radians.
CRadians operator/(Real f_value) const
CRadians & operator*=(Real f_value)
static const CRadians TWO_PI
Set to PI * 2.
static const CRadians PI_OVER_FOUR
Set to PI / 4.
Real operator/(const CRadians &c_radians) const
CRadians & operator/=(Real f_value)
friend CRadians NormalizedDifference(const CRadians &c_rad1, const CRadians &c_rad2)
Calculates the normalized difference between the given angles.
friend CDegrees ToDegrees(const CRadians &c_radians)
Converts this object to CDegrees.
CRadians operator-() const
bool operator>=(const CRadians &c_radians) const
void FromValueInDegrees(Real f_value)
Sets the value from a value in degrees It sets m_fValue (which is in radians) converting from the pas...
static const CRange< CRadians > UNSIGNED_RANGE
The unsigned normalization range [0:TWO_PI].
bool operator>(const CRadians &c_radians) const
CRadians operator-(const CRadians &c_radians) const
bool operator<(const CRadians &c_radians) const
static const CRadians PI_OVER_TWO
Set to PI / 2.
CRadians operator+(const CRadians &c_radians) const
CRadians()
Class constructor It initializes m_fValue to 0 radians.
friend CRadians operator*(Real f_value, const CRadians &c_radians)
static const CRadians PI_OVER_SIX
Set to PI / 6.
static const CRadians PI_OVER_THREE
Set to PI / 3.
friend std::ostream & operator<<(std::ostream &c_os, const CRadians &c_radians)
CRadians & SignedNormalize()
Normalizes the value in the range [-PI:PI].
static const Real RADIANS_TO_DEGREES
Constant to convert from radians to degrees.
static const CRadians ZERO
Set to zero radians.
bool operator==(const CRadians &c_radians) const
friend std::istream & operator>>(std::istream &is, CRadians &c_radians)
Real GetValue() const
Returns the value in radians.
CRadians & operator+=(const CRadians &c_radians)
Real GetAbsoluteValue() const
Returns the absolute value in radians.
It defines the basic type CDegrees, used to store an angle value in degrees.
Real GetAbsoluteValue() const
Returns the absolute value in degrees.
CDegrees()
Class constructor It initializes m_fValue to 0 degrees.
bool operator>=(const CDegrees &c_degrees) const
friend CDegrees operator*(Real f_value, const CDegrees &c_degrees)
CDegrees operator*(Real f_value) const
bool operator==(const CDegrees &c_degrees) const
CDegrees & UnsignedNormalize()
Normalizes the value in the range [0:360].
CDegrees operator+(const CDegrees &c_degrees) const
CDegrees & operator*=(Real f_value)
void SetValue(Real f_value)
Sets the value in degrees.
CDegrees & operator+=(const CDegrees &c_degrees)
CDegrees operator-() const
friend CRadians ToRadians(const CDegrees &c_degrees)
Converts this object to CRadians.
void FromValueInRadians(Real f_value)
Sets the value from a value in radians It sets m_fValue (which is in degrees) converting from the pas...
CDegrees & operator-=(const CDegrees &c_degrees)
bool operator>(const CDegrees &c_degrees) const
friend std::ostream & operator<<(std::ostream &c_os, const CDegrees &c_degrees)
CDegrees & SignedNormalize()
Normalizes the value in the range [-180:180].
bool operator<=(const CDegrees &c_degrees) const
bool operator<(const CDegrees &c_degrees) const
CDegrees operator/(Real f_value) const
CDegrees operator-(const CDegrees &c_degrees) const
CDegrees(Real f_value)
Class constructor It initializes m_fValue to the passed value.
Real GetValue() const
Returns the value in degrees.
bool operator!=(const CDegrees &c_degrees) const
Real operator/(const CDegrees &c_degrees) const
friend CDegrees NormalizedDifference(const CDegrees &c_angle1, const CDegrees &c_angle2)
Calculates the normalized difference between the given angles.
CDegrees & operator/=(Real f_value)
friend std::istream & operator>>(std::istream &is, CDegrees &c_degrees)