9 #ifndef _TurtleBrains_Math_h_
10 #define _TurtleBrains_Math_h_
12 #include "../core/tb_configuration.h"
13 #include "tb_constants.h"
30 inline bool IsEqual(
const float leftValue,
const float rightValue,
const float tolerance = tbMath::kTolerance)
32 return fabsf(leftValue - rightValue) <= tolerance;
36 inline bool IsEqual(
const double leftValue,
const double rightValue,
const double tolerance = tbMath::kTolerance)
38 return fabs(leftValue - rightValue) <= tolerance;
49 inline bool IsZero(
const float value,
const float tolerance = tbMath::kTolerance)
51 return (fabsf(value)) <= tolerance;
55 inline bool IsZero(
const double value,
const double tolerance = tbMath::kTolerance)
57 return (fabs(value)) <= tolerance;
68 template <
typename T> constexpr
const T&
Maximum(
const T& leftValue,
const T& rightValue) noexcept
70 return (leftValue < rightValue) ? rightValue : leftValue;
81 template <
typename T> constexpr
const T&
Minimum(
const T& leftValue,
const T& rightValue) noexcept
83 return (leftValue < rightValue) ? leftValue : rightValue;
98 template <
typename T> constexpr
const T&
Clamp(
const T& value,
const T& minimumValue,
const T& maximumValue) noexcept
100 return (value < minimumValue) ? minimumValue : (maximumValue < value) ? maximumValue : value;
Contains objects and functions for dealing with Vector and Matrix math.
Here is some information about the primary namespace.
Definition: tb_application_dialog.h:21
constexpr const T & Clamp(const T &value, const T &minimumValue, const T &maximumValue) noexcept
Definition: tb_math.h:98
bool IsZero(const float value, const float tolerance=tbMath::kTolerance)
Definition: tb_math.h:49
constexpr const T & Maximum(const T &leftValue, const T &rightValue) noexcept
Definition: tb_math.h:68
bool IsEqual(const float leftValue, const float rightValue, const float tolerance=tbMath::kTolerance)
Definition: tb_math.h:30
constexpr const T & Minimum(const T &leftValue, const T &rightValue) noexcept
Definition: tb_math.h:81