9 #ifndef TurtleBrains_Math_hpp
10 #define TurtleBrains_Math_hpp
12 #include <turtle_brains/core/tb_configuration.hpp>
13 #include <turtle_brains/math/tb_constants.hpp>
29 template<
typename Type> constexpr
const Type&
Maximum(
const Type& leftValue,
const Type& rightValue) noexcept
31 return (leftValue < rightValue) ? rightValue : leftValue;
42 template<
typename Type> constexpr
const Type&
Minimum(
const Type& leftValue,
const Type& rightValue) noexcept
44 return (leftValue < rightValue) ? leftValue : rightValue;
56 template<
typename Type>
bool IsEqual(
const Type& leftValue,
const Type& rightValue,
const Type tolerance = tbMath::kTolerance)
63 return std::fabs(leftValue - rightValue) <= Maximum<Type>(Type(tolerance), Type(tolerance * std::fabs(leftValue)));
74 template<
typename Type>
bool IsZero(
const Type& value,
const Type tolerance = tbMath::kTolerance)
76 return std::fabs(value) <= tolerance;
91 template<
typename Type> constexpr
const Type&
Clamp(
const Type& value,
const Type& minimumValue,
const Type& maximumValue) noexcept
93 return (value < minimumValue) ? minimumValue : (maximumValue < value) ? maximumValue : value;
99 template<
typename Type> Type
Sign(
const Type& value) noexcept
101 return IsZero(value) ? Type(0) : (std::signbit(value) ? Type(-1) : Type(1));
Contains objects and functions for dealing with Vector and Matrix math.
bool IsZero(const Type &value, const Type tolerance=tbMath::kTolerance)
Definition: tb_math.hpp:74
bool IsEqual(const Type &leftValue, const Type &rightValue, const Type tolerance=tbMath::kTolerance)
Definition: tb_math.hpp:56
Type Sign(const Type &value) noexcept
Definition: tb_math.hpp:99
constexpr const Type & Minimum(const Type &leftValue, const Type &rightValue) noexcept
Definition: tb_math.hpp:42
constexpr const Type & Clamp(const Type &value, const Type &minimumValue, const Type &maximumValue) noexcept
Definition: tb_math.hpp:91
constexpr const Type & Maximum(const Type &leftValue, const Type &rightValue) noexcept
Definition: tb_math.hpp:29
Here is some information about the primary namespace.
Definition: tb_application_dialog.hpp:22