12 #include <argos3/core/utility/datatypes/datatypes.h>
25 template<
typename T> T
Abs(
const T& t_v) {
26 if (t_v > T(0))
return t_v;
27 if (t_v < T(0))
return -t_v;
38 if (t_v > 0)
return t_v;
39 if (t_v < 0)
return -t_v;
49 if (t_v > 0.0f)
return t_v;
50 if (t_v < 0.0f)
return -t_v;
57 #ifdef ARGOS_USE_DOUBLE
77 template<
typename T> T
Min(
const T& t_v1,
const T& t_v2) {
78 return t_v1 < t_v2 ? t_v1 : t_v2;
86 template<
typename T> T&
Min(T& t_v1, T& t_v2) {
87 return t_v1 < t_v2 ? t_v1 : t_v2;
95 template<
typename T> T
Max(
const T& t_v1,
const T& t_v2) {
96 return t_v1 > t_v2 ? t_v1 : t_v2;
104 template<
typename T> T&
Max(T& t_v1, T& t_v2) {
105 return t_v1 > t_v2 ? t_v1 : t_v2;
116 if (t_v > T(0))
return 1;
117 if (t_v < T(0))
return -1;
128 template<
typename T> T
Square(
const T& t_v) {
142 if (f_value >= 0.0f)
return nI;
153 if (nI < f_value)
return nI + 1;
163 if (f_value > 0.0f)
return Floor(f_value + 0.5f);
164 return Ceil(f_value - 0.5f);
173 if (f_value > 0.0f)
return Floor(f_value);
174 return Ceil(f_value);
195 return Abs<Real > (f_value1 - f_value2) <= f_epsilon * Max<Real > (1.0f, Max<Real > (Abs<Real > (f_value1), Abs<Real > (f_value2)));
207 return Abs<Real > (f_value1 - f_value2) <= 0.0001f * Max<Real > (1.0f, Max<Real > (Abs<Real > (f_value1), Abs<Real > (f_value2)));
220 std::pair<Real, Real> cP0 = c_points.at(0);
221 std::pair<Real, Real> cP1;
222 for (
UInt32 i = 1; i < c_points.size(); ++i) {
223 cP1 = c_points.at(i);
224 if (cP1.first >= f_x) {
226 }
else if (i < c_points.size() - 1) {
230 return (f_x * (cP0.second - cP1.second)) / (cP0.first - cP1.first)+(-cP1.first * cP0.second + cP0.first * cP1.second) / (cP0.first - cP1.first);;
signed int SInt32
32-bit signed integer.
unsigned int UInt32
32-bit unsigned integer.
float Real
Collects all ARGoS code.
The namespace containing all the ARGoS related code.
bool DoubleEqAbsolute(Real f_value1, Real f_value2, Real f_epsilon)
Tests whether a floating-point value is lower than another.
T Square(const T &t_v)
Returns the square of the value of the passed argument.
bool DoubleEq(Real f_value1, Real f_value2)
Tests whether a floating-point value is lower than another.
SInt32 Ceil(Real f_value)
Rounds the passed floating-point value to the closest higher integer.
SInt32 Round(Real f_value)
Rounds the passed floating-point value to the closest integer.
Real Interpolate(Real f_x, const std::vector< std::pair< Real, Real > > &c_points)
Return the value of the linear interpolation.
SInt32 Sign(const T &t_v)
Returns the sign of the value of the passed argument.
SInt32 Floor(Real f_value)
Rounds the passed floating-point value to the closest lower integer.
SInt32 RoundClosestToZero(Real f_value)
Rounds the passed floating-point value to the integer closest to zero.
T Max(const T &t_v1, const T &t_v2)
Returns the bigger of the two passed arguments.
T Abs(const T &t_v)
Returns the absolute value of the passed argument.
T Min(const T &t_v1, const T &t_v2)
Returns the smaller of the two passed arguments.