Go to the documentation of this file.
25 #include "spdlog/fmt/ostr.h"
26 #include "spdlog/spdlog.h"
39 #define AD_PHYSICS_RATIOVALUE_THROWS_EXCEPTION 1
41 #if SAFE_DATATYPES_EXPLICIT_CONVERSION
45 #define _AD_PHYSICS_RATIOVALUE_EXPLICIT_CONVERSION_ explicit
50 #define _AD_PHYSICS_RATIOVALUE_EXPLICIT_CONVERSION_
85 : mRatioValue(std::numeric_limits<double>::quiet_NaN())
95 : mRatioValue(iRatioValue)
166 return (mRatioValue > other.mRatioValue) &&
operator!=(other);
182 return (mRatioValue < other.mRatioValue) &&
operator!=(other);
198 return ((mRatioValue > other.mRatioValue) ||
operator==(other));
214 return ((mRatioValue < other.mRatioValue) ||
operator==(other));
231 RatioValue const result(mRatioValue + other.mRatioValue);
250 mRatioValue += other.mRatioValue;
269 RatioValue const result(mRatioValue - other.mRatioValue);
288 mRatioValue -= other.mRatioValue;
306 RatioValue const result(mRatioValue * scalar);
324 RatioValue const result(
operator/(scalarRatioValue));
344 double const result = mRatioValue / other.mRatioValue;
384 auto const valueClass = std::fpclassify(mRatioValue);
385 return ((valueClass == FP_NORMAL) || (valueClass == FP_ZERO)) && (
cMinValue <= mRatioValue)
399 spdlog::info(
"ensureValid(::ad::physics::RatioValue)>> {} value out of range", *
this);
400 #if (AD_PHYSICS_RATIOVALUE_THROWS_EXCEPTION == 1)
401 throw std::out_of_range(
"RatioValue value out of range");
417 spdlog::info(
"ensureValid(::ad::physics::RatioValue)>> {} value is zero", *
this);
418 #if (AD_PHYSICS_RATIOVALUE_THROWS_EXCEPTION == 1)
419 throw std::out_of_range(
"RatioValue value is zero");
470 return value.operator*(other);
481 inline ::ad::physics::RatioValue
fabs(const ::ad::physics::RatioValue other)
501 static inline ::ad::physics::RatioValue
lowest()
503 return ::ad::physics::RatioValue::getMin();
508 static inline ::ad::physics::RatioValue
max()
510 return ::ad::physics::RatioValue::getMax();
516 static inline ::ad::physics::RatioValue
epsilon()
518 return ::ad::physics::RatioValue::getPrecision();
527 #ifndef GEN_GUARD_AD_PHYSICS_RATIOVALUE
528 #define GEN_GUARD_AD_PHYSICS_RATIOVALUE
549 return os << double(_value);
561 return to_string(
static_cast<double>(value));
564 #endif // GEN_GUARD_AD_PHYSICS_RATIOVALUE
namespace ad
Definition: Acceleration.hpp:30
bool operator==(const RatioValue &other) const
standard comparison operator
Definition: RatioValue.hpp:134
RatioValue & operator=(const RatioValue &other)=default
standard assignment operator
inline ::ad::physics::RatioValue operator*(const double &other, ::ad::physics::RatioValue const &value)
standard arithmetic operator
Definition: RatioValue.hpp:468
RatioValue operator-=(const RatioValue &other)
standard arithmetic operator
Definition: RatioValue.hpp:284
static inline ::ad::physics::RatioValue max()
Definition: RatioValue.hpp:508
bool operator!=(const RatioValue &other) const
standard comparison operator
Definition: RatioValue.hpp:148
DataType RatioValue.
Definition: RatioValue.hpp:59
static const double cPrecisionValue
constant defining the assumed RatioValue value accuracy (used in comparison operator==(),...
Definition: RatioValue.hpp:76
static inline ::ad::physics::RatioValue epsilon()
Definition: RatioValue.hpp:516
RatioValue()
default constructor
Definition: RatioValue.hpp:84
#define _AD_PHYSICS_RATIOVALUE_EXPLICIT_CONVERSION_
Enable/Disable explicit conversion. Currently set to "implicit conversion allowed".
Definition: RatioValue.hpp:50
bool operator<(const RatioValue &other) const
standard comparison operator
Definition: RatioValue.hpp:178
bool isValid() const
Definition: RatioValue.hpp:382
bool operator>=(const RatioValue &other) const
standard comparison operator
Definition: RatioValue.hpp:194
static const double cMinValue
constant defining the minimum valid RatioValue value (used in isValid())
Definition: RatioValue.hpp:65
RatioValue operator*(const double &scalar) const
standard arithmetic operator
Definition: RatioValue.hpp:303
bool operator<=(const RatioValue &other) const
standard comparison operator
Definition: RatioValue.hpp:210
RatioValue operator-() const
standard arithmetic operator
Definition: RatioValue.hpp:356
static RatioValue getPrecision()
get assumed accuracy of RatioValue (i.e. cPrecisionValue)
Definition: RatioValue.hpp:443
RatioValue operator+(const RatioValue &other) const
standard arithmetic operator
Definition: RatioValue.hpp:227
static inline ::ad::physics::RatioValue lowest()
Definition: RatioValue.hpp:501
bool operator>(const RatioValue &other) const
standard comparison operator
Definition: RatioValue.hpp:162
static RatioValue getMin()
get minimum valid RatioValue (i.e. cMinValue)
Definition: RatioValue.hpp:427
static RatioValue getMax()
get maximum valid RatioValue (i.e. cMaxValue)
Definition: RatioValue.hpp:435
inline ::ad::physics::Weight fabs(const ::ad::physics::Weight other)
overload of the std::fabs for Weight
Definition: Weight.hpp:480
void ensureValidNonZero() const
ensure that the RatioValue is valid and non zero
Definition: RatioValue.hpp:412
inline ::ad::physics::Acceleration fabs(const ::ad::physics::Acceleration other)
overload of the std::fabs for Acceleration
Definition: Acceleration.hpp:481
RatioValue & operator+=(const RatioValue &other)
standard arithmetic operator
Definition: RatioValue.hpp:246
std::string to_string(::ad::physics::Acceleration const &value)
overload of the std::to_string for Acceleration
Definition: Acceleration.hpp:559
double operator/(const RatioValue &other) const
standard arithmetic operator
Definition: RatioValue.hpp:340
void ensureValid() const
ensure that the RatioValue is valid
Definition: RatioValue.hpp:395
std::ostream & operator<<(std::ostream &os, Acceleration const &_value)
standard ostream operator
Definition: Acceleration.hpp:547
RatioValue operator-(const RatioValue &other) const
standard arithmetic operator
Definition: RatioValue.hpp:265
static const double cMaxValue
constant defining the maximum valid RatioValue value (used in isValid())
Definition: RatioValue.hpp:70
_AD_PHYSICS_RATIOVALUE_EXPLICIT_CONVERSION_ RatioValue(double const iRatioValue)
standard constructor
Definition: RatioValue.hpp:94
RatioValue operator/(const double &scalar) const
standard arithmetic operator
Definition: RatioValue.hpp:321