| VRS - The Virtual Rendering System |
| version 3.3 |
#include <vrs/utils.h>
Static Public Member Functions | |
| static double | round (double value, unsigned int dp=0) |
| rounds value to a value with 'dp' decimal places. | |
| static double | modulus (double x, double y) |
| static float | modulus (float x, float y) |
| static double | random (double lower, double upper) |
| generate random numbers in the range [lower; upper] | |
| static float | random (float lower, float upper) |
| static int | random (int lower, int upper) |
| static bool | random () |
| template<typename T> | |
| static T | clamp (const T &minimum, const T &value, const T &maximum) |
| template<typename T> | |
| static T | lerp (double t, const T &a, const T &b) |
| linear interpolation between a and b if t is in [0; 1]. | |
| template<typename T> | |
| static T | smoothStep (double x, T a, T b, double left=0.0f, double right=1.0f) |
| cubic interpolation between a and b if x is within ]left; right[. | |
| static bool | isPow2 (VRS::UINT64 value) |
| Returns true if value is a power of 2. | |
| static unsigned int | powerOf10ui (unsigned int i) |
| Fast power of the impl (using static uint array). Note: i shall never exeed 9. | |
| static VRS::UINT64 | roundToPow2 (VRS::UINT64 value) |
| Rounds up value to be a power of 2. | |
| static VRS::UINT64 | log2 (VRS::UINT64 value) |
| Returns the (integral) log of 2 of value. (e.g. log2(15) = 3, log2(16) = 4). | |
| static double VRS::Utils::round | ( | double | value, | |
| unsigned int | dp = 0 | |||
| ) | [static] |
rounds value to a value with 'dp' decimal places.
with dp's default parameter (dp = 0) the value is rounded to the closest integer
| static double VRS::Utils::modulus | ( | double | x, | |
| double | y | |||
| ) | [inline, static] |
| static float VRS::Utils::modulus | ( | float | x, | |
| float | y | |||
| ) | [inline, static] |
| static double VRS::Utils::random | ( | double | lower, | |
| double | upper | |||
| ) | [static] |
generate random numbers in the range [lower; upper]
| static float VRS::Utils::random | ( | float | lower, | |
| float | upper | |||
| ) | [static] |
| static int VRS::Utils::random | ( | int | lower, | |
| int | upper | |||
| ) | [static] |
| static bool VRS::Utils::random | ( | ) | [static] |
| static T VRS::Utils::clamp | ( | const T & | minimum, | |
| const T & | value, | |||
| const T & | maximum | |||
| ) | [inline, static] |
| static T VRS::Utils::lerp | ( | double | t, | |
| const T & | a, | |||
| const T & | b | |||
| ) | [inline, static] |
linear interpolation between a and b if t is in [0; 1].
if t is not within these bounds, the value is extrapolated.
| static T VRS::Utils::smoothStep | ( | double | x, | |
| T | a, | |||
| T | b, | |||
| double | left = 0.0f, |
|||
| double | right = 1.0f | |||
| ) | [inline, static] |
cubic interpolation between a and b if x is within ]left; right[.
outside that range, the value is clamped to a and b.
| static bool VRS::Utils::isPow2 | ( | VRS::UINT64 | value | ) | [static] |
Returns true if value is a power of 2.
| static unsigned int VRS::Utils::powerOf10ui | ( | unsigned int | i | ) | [static] |
Fast power of the impl (using static uint array). Note: i shall never exeed 9.
| static VRS::UINT64 VRS::Utils::roundToPow2 | ( | VRS::UINT64 | value | ) | [static] |
Rounds up value to be a power of 2.
| static VRS::UINT64 VRS::Utils::log2 | ( | VRS::UINT64 | value | ) | [static] |
Returns the (integral) log of 2 of value. (e.g. log2(15) = 3, log2(16) = 4).