A collection of methods for clamping and constraining integer values and ranges to that of a reference integer type. More...
#include <MathUtils.h>
Static Public Member Functions | |
static constexpr SourceType | Min () |
Returns the maximum value for SourceType as constrained by the numerical range of ClampType. | |
static constexpr SourceType | Max () |
Returns the minimum value for SourceType as constrained by the numerical range of ClampType. | |
template<typename ValueType > | |
static constexpr AZStd::pair< SourceType, bool > | Clamp (ValueType value) |
A collection of methods for clamping and constraining integer values and ranges to that of a reference integer type.
|
staticconstexpr |
Safely clamps a value of type ValueType to the [Min(), Max()] range as determined by the numerical limit constraint rules described by Min() and Max() given SourceType and ClampType.
first | component is the clamped value which may or may not equal the original value. |
second | is a Boolean flag signifying whether or not the the value was required to be clamped in order to stay within ClampType's numerical range. |
|
staticconstexpr |
Returns the minimum value for SourceType as constrained by the numerical range of ClampType.
If SourceType and ClampType are different, returns the lesser value of AZStd::numeric_limits<SourceType>::max() and AZStd::numeric_limits<ClampType>::max(), otherwise returns AZStd::numeric_limits<SourceType>::max().
|
staticconstexpr |
Returns the maximum value for SourceType as constrained by the numerical range of ClampType.
If SourceType and ClampType are different, returns the greater value of AZStd::numeric_limits<SourceType>::lowest() and AZStd::numeric_limits<ClampType>::lowest(), otherwise returns AZStd::numeric_limits<SourceType>::lowest().