soo
3D game math library
Loading...
Searching...
No Matches
soo::util Namespace Reference

Namespace for utility functions. More...

Functions

template<typename T>
requires std::is_arithmetic_v<T>
bool isEqual (const T a, const T b, const T tolerance=DEFAULT_TOLERANCE)
template<std::ranges::range Range>
requires std::is_arithmetic_v<std::ranges::range_value_t<Range>>
bool isEqual (const Range &a, const Range &b, const std::ranges::range_value_t< Range > tolerance=DEFAULT_TOLERANCE)
template<typename T>
requires std::is_arithmetic_v<T>
bool isZero (const T num, const T tolerance=DEFAULT_TOLERANCE)
template<typename T, std::floating_point FP>
lerp (const T a, const T b, const FP alpha)

Variables

constexpr double DEFAULT_TOLERANCE = 1e-8

Detailed Description

Namespace for utility functions.

Function Documentation

◆ isEqual() [1/2]

template<std::ranges::range Range>
requires std::is_arithmetic_v<std::ranges::range_value_t<Range>>
bool soo::util::isEqual ( const Range & a,
const Range & b,
const std::ranges::range_value_t< Range > tolerance = DEFAULT_TOLERANCE )

Compares elements of two containers.

Template Parameters
RangeElements' type must be arithmetic.
Returns
True if given containers' entries are identical.

◆ isEqual() [2/2]

template<typename T>
requires std::is_arithmetic_v<T>
bool soo::util::isEqual ( const T a,
const T b,
const T tolerance = DEFAULT_TOLERANCE )
Template Parameters
TArithmetic types only.
Returns
True if the given values are nearly equal.

◆ isZero()

template<typename T>
requires std::is_arithmetic_v<T>
bool soo::util::isZero ( const T num,
const T tolerance = DEFAULT_TOLERANCE )
Template Parameters
TArithmetic types only.
Returns
True if the given value is nearly zero.

◆ lerp()

template<typename T, std::floating_point FP>
T soo::util::lerp ( const T a,
const T b,
const FP alpha )

Linear interpolation between two values.

Template Parameters
TFloating-point type.
Parameters
aFirst value.
bSecond value.
alphaInterpolation factor (0.0 ~ 1.0).
Returns
Weighted average of a and b.

Variable Documentation

◆ DEFAULT_TOLERANCE

double soo::util::DEFAULT_TOLERANCE = 1e-8
constexpr

Used as the default arguments in comparison functions.