Go to the documentation of this file.
25 #include "spdlog/fmt/ostr.h"
26 #include "spdlog/spdlog.h"
39 #define AD_PHYSICS_SPEED_THROWS_EXCEPTION 1
41 #if SAFE_DATATYPES_EXPLICIT_CONVERSION
45 #define _AD_PHYSICS_SPEED_EXPLICIT_CONVERSION_ explicit
50 #define _AD_PHYSICS_SPEED_EXPLICIT_CONVERSION_
94 : mSpeed(std::numeric_limits<double>::quiet_NaN())
175 return (mSpeed > other.mSpeed) &&
operator!=(other);
191 return (mSpeed < other.mSpeed) &&
operator!=(other);
207 return ((mSpeed > other.mSpeed) ||
operator==(other));
223 return ((mSpeed < other.mSpeed) ||
operator==(other));
240 Speed const result(mSpeed + other.mSpeed);
259 mSpeed += other.mSpeed;
278 Speed const result(mSpeed - other.mSpeed);
297 mSpeed -= other.mSpeed;
328 Speed const result(mSpeed * scalar);
345 Speed const scalarSpeed(scalar);
346 Speed const result(
operator/(scalarSpeed));
366 double const result = mSpeed / other.mSpeed;
381 Speed const result(-mSpeed);
406 auto const valueClass = std::fpclassify(mSpeed);
407 return ((valueClass == FP_NORMAL) || (valueClass == FP_ZERO)) && (
cMinValue <= mSpeed) && (mSpeed <=
cMaxValue);
420 spdlog::info(
"ensureValid(::ad::physics::Speed)>> {} value out of range", *
this);
421 #if (AD_PHYSICS_SPEED_THROWS_EXCEPTION == 1)
422 throw std::out_of_range(
"Speed value out of range");
436 if (
operator==(
Speed(0.)))
438 spdlog::info(
"ensureValid(::ad::physics::Speed)>> {} value is zero", *
this);
439 #if (AD_PHYSICS_SPEED_THROWS_EXCEPTION == 1)
440 throw std::out_of_range(
"Speed value is zero");
491 return value.operator*(other);
502 inline ::ad::physics::Speed
fabs(const ::ad::physics::Speed other)
522 static inline ::ad::physics::Speed
lowest()
524 return ::ad::physics::Speed::getMin();
529 static inline ::ad::physics::Speed
max()
531 return ::ad::physics::Speed::getMax();
539 return ::ad::physics::Speed::getPrecision();
548 #ifndef GEN_GUARD_AD_PHYSICS_SPEED
549 #define GEN_GUARD_AD_PHYSICS_SPEED
570 return os << double(_value);
582 return to_string(
static_cast<double>(value));
585 #endif // GEN_GUARD_AD_PHYSICS_SPEED
namespace ad
Definition: Acceleration.hpp:30
bool operator<=(const Speed &other) const
standard comparison operator
Definition: Speed.hpp:219
static const double cMaxValue
constant defining the maximum valid Speed value (used in isValid())
Definition: Speed.hpp:79
double operator/(const Speed &other) const
standard arithmetic operator
Definition: Speed.hpp:362
inline ::ad::physics::Speed operator*(const double &other, ::ad::physics::Speed const &value)
standard arithmetic operator
Definition: Speed.hpp:489
bool operator!=(const Speed &other) const
standard comparison operator
Definition: Speed.hpp:157
static inline ::ad::physics::Speed max()
Definition: Speed.hpp:529
SpeedSquared operator*(const Speed &other) const
standard arithmetic operator
DataType Speed.
Definition: Speed.hpp:68
static Speed getPrecision()
get assumed accuracy of Speed (i.e. cPrecisionValue)
Definition: Speed.hpp:464
Speed operator-() const
standard arithmetic operator
Definition: Speed.hpp:378
Speed & operator+=(const Speed &other)
standard arithmetic operator
Definition: Speed.hpp:255
bool operator<(const Speed &other) const
standard comparison operator
Definition: Speed.hpp:187
void ensureValid() const
ensure that the Speed is valid
Definition: Speed.hpp:416
_AD_PHYSICS_SPEED_EXPLICIT_CONVERSION_ Speed(double const iSpeed)
standard constructor
Definition: Speed.hpp:103
bool operator>(const Speed &other) const
standard comparison operator
Definition: Speed.hpp:171
Speed operator*(const double &scalar) const
standard arithmetic operator
Definition: Speed.hpp:325
Speed operator-(const Speed &other) const
standard arithmetic operator
Definition: Speed.hpp:274
bool isValid() const
Definition: Speed.hpp:404
static inline ::ad::physics::Speed lowest()
Definition: Speed.hpp:522
static const double cPrecisionValue
constant defining the assumed Speed value accuracy (used in comparison operator==(),...
Definition: Speed.hpp:85
static const double cMinValue
constant defining the minimum valid Speed value (used in isValid())
Definition: Speed.hpp:74
bool operator==(const Speed &other) const
standard comparison operator
Definition: Speed.hpp:143
#define _AD_PHYSICS_SPEED_EXPLICIT_CONVERSION_
Enable/Disable explicit conversion. Currently set to "implicit conversion allowed".
Definition: Speed.hpp:50
Speed & operator=(const Speed &other)=default
standard assignment operator
static inline ::ad::physics::Speed epsilon()
Definition: Speed.hpp:537
DataType SpeedSquared.
Definition: SpeedSquared.hpp:67
inline ::ad::physics::Weight fabs(const ::ad::physics::Weight other)
overload of the std::fabs for Weight
Definition: Weight.hpp:480
inline ::ad::physics::Acceleration fabs(const ::ad::physics::Acceleration other)
overload of the std::fabs for Acceleration
Definition: Acceleration.hpp:481
std::string to_string(::ad::physics::Acceleration const &value)
overload of the std::to_string for Acceleration
Definition: Acceleration.hpp:559
void ensureValidNonZero() const
ensure that the Speed is valid and non zero
Definition: Speed.hpp:433
bool operator>=(const Speed &other) const
standard comparison operator
Definition: Speed.hpp:203
static Speed getMin()
get minimum valid Speed (i.e. cMinValue)
Definition: Speed.hpp:448
Speed()
default constructor
Definition: Speed.hpp:93
static Speed getMax()
get maximum valid Speed (i.e. cMaxValue)
Definition: Speed.hpp:456
Speed operator/(const double &scalar) const
standard arithmetic operator
Definition: Speed.hpp:343
std::ostream & operator<<(std::ostream &os, Acceleration const &_value)
standard ostream operator
Definition: Acceleration.hpp:547
Speed operator+(const Speed &other) const
standard arithmetic operator
Definition: Speed.hpp:236
Speed operator-=(const Speed &other)
standard arithmetic operator
Definition: Speed.hpp:293